Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Memory leak in file DELETE in R2010b?
Replies: 3   Last Post: Sep 4, 2012 3:43 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Kevin Hung

Posts: 81
Registered: 12/7/04
Memory leak in file DELETE in R2010b?
Posted: Apr 1, 2011 5:34 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hi everyone,

Can someone kindly try out the following Matlab codes? I am not sure if I have found out a memory leak in using DELETE to simply delete a file.

I bracketed the DELETE command with the MEMORY command so that I can see the memory usage before and after calling DELETE.

Look at the line "Maximum possible array: ....". This number is constant at the beginning but before we hit 100 iterations, this number will decrease.

This took me 3 hours to find out. Am I missing something?

Kevin

--------------------------------------------------------------------------------

%% Create file1.mat in current directory.
file1 = 'file1.mat';
save(file1);

for n = 1:100

%% Create file2.mat.
file2 = 'file2.mat';
copyfile(file1, file2);

%% Delete file2.mat.
if exist(file2, 'file') ~= 0
memory
delete(file2);
memory
fprintf('--------------------------------------------\n\n');
end
if exist(file2, 'file') ~= 0
error('Cannot delete file2.mat.');
end

end



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.