Troubleshooting Memory Leaks in Matlab?

24 Ansichten (letzte 30 Tage)
Nathan
Nathan am 19 Jun. 2014
Kommentiert: Nathan am 7 Aug. 2014
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 Kommentare
dpb
dpb am 19 Jun. 2014
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 am 7 Aug. 2014
thanks for the tip on memmapfile. It the issue presses itself, I'll check that out.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Performance and Memory finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by