Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm trying to run a script on matlab_2011a, which calculate same means for a climatology of 50 years. When I started to run the script for all the years it worked fine until the iteration 20th, and then appeared the message:

Out of memory. Type HELP MEMORY for your options. 

Then I used clear v1 v2 v3 ... to clear all the variables inside the function, also i used clear train because i saw it in another forum, and these with the modifications or not, I run again the script (since the 21th iteration), and the result is the same message, but curiously sometimes it run a year and then stop.

Any ideas about solving this problem?, what I have to clean to run correctly? (in this matlab version there's not the command memory which maybe could help me).

EDIT

Solution: There was a variable that was too large, saving the results differently prevented the out of memory error.

share|improve this question
add comment

2 Answers

I am not an avid MATLAB user, but may I suggest you to try:

File > Preferences > General > Java Heap Memory. 

Then you can increase the amount of memory beyond the default value of 196 MB. Hope this helps.

share|improve this answer
    
I tried putting to the maximum 795 MB, but it still doesn't work for more than a year .. I think that the problem could be related with other kind of temporary memory, which I don't know how to clean it up for each iteration .. Anyway thanks for the answer E.- –  Eric Sánchez Nov 11 '12 at 17:39
    
Eric, the best way to handle a memory problem safe code in MATLAB is to write modular code i.e. write your functions and avoid Global Variables. –  Indian Nov 12 '12 at 3:24
add comment

Memory management is a long standing problem for Matlab. The most likely cause of your out of memory error is that there is a memory leak. Memory leaks can be found, but finding them is technically challenging and time consuming.

To completely free up the memory, Matlab needs to be restarted. If there is a way to save the results after processing some of the data, save the data and restart Matlab. Reload the data and process another another chuck of data. Repeat until all the data is processed. The amount of data to process should be less than 20 years.

This is far from elegant and depends on being able to save and reload the data. Also, I assume that the size of the data itself is not the problem.

share|improve this answer
    
Thanks for the Help. I realized that the structure variable where I was saving all the means was too big, so when i change the name of the output the script run without problems .. –  Eric Sánchez Nov 11 '12 at 23:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.