Troubleshooting Memory Leaks in Matlab?

조회 수: 19 (최근 30일)
Nathan
Nathan 2014년 6월 19일
댓글: Nathan 2014년 8월 7일
I was wondering if anyone knows where to find a good guide on troubleshooting memory leaks specifically ones that happen in matlab. I'm running a Global Optimization and one of the sub-functions that the objective function calls: tests if a file exists, if it doesn't it creates a file then my method uses that file to do some calculations and the deletes the file from the hard drive. This happens 10,000's to 100,000's of times in a 12 hour period while the code runs. system momory is about 2.3 - 3 Gig when started clean with matlab running. After running the algorithm the system memory is about 7 Gig in use. clear all does nothing to change that. closing matlab and waiting 5 minutes and the memory goes back down to the 2.5 - 3 Gig range. I've written other code that does everything but the writing of files and deleting them after calculation, so I assume it has something to do with that.
I'm using fopen, fprintf and fclose to write the file and the delete command to delete it from the hard drive.
Any suggestions on how to troubleshoot this and or document it properly for submission of a possible bug report are welcome.
BTW I'm using a windows 7 machine with R2014a.
  댓글 수: 2
dpb
dpb 2014년 6월 19일
I'd guess it's actually a fignewton of the OS and "lazy" deallocate/reclamation that the memory is flagged as clear but as long as the application is running there's no opportunity for the OS to actually release it.
Try creating a memmapfile object instead of a disk file -- it may have a better chance of releasing or reusing memory and likely will have better performance besides.
It's always worth a query to official TMW support at www.mathworks.com; particularly if you can cut your code down to a bare-bones app that creates the issue but is small in size--it may be that simply the file creation/deletion alone will demonstrate the issue I'd guess.
Nathan
Nathan 2014년 8월 7일
thanks for the tip on memmapfile. It the issue presses itself, I'll check that out.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Performance and Memory에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by