MatLab have memory leaks?

4 visualizaciones (últimos 30 días)
Lucas el 2 de Jul. de 2012
When I open MatLab at the beginning it takes up less than 200k in memory. When I open a Simulink model it jumps up to over 300k and every time I press the play button it add 1-2k onto the total memory usage. Sometimes when I run, I get a segmentation violation crash. Its’ happened quite a bit today, but I’m not able to recreate it. I looked the error up and it said that it usually happens when you access something outside of an array index.
I tried to get my program to crash and I threw everything I had at it but to no avail. I checked my memory usage and I was over 700k. I did a clear all and it only freed up about 5k. I didn’t know if it was cause by me trying to access a memory location that was leaked. Does MatLab free up its own memory, or is there a way for me to check to see if anything was leaked?
MATLAB crash file:T:\Temp\matlab\matlab_crash_dump.4064-1:
Segmentation violation detected at Mon Jul 02 15:01:04 2012
Crash Decoding : Disabled
Default Encoding: windows-1252
MATLAB Root : K:\PROD\wnt\matlab\2012a\win32
MATLAB Version : (R2012a)
Operating System: Microsoft Windows XP
Processor ID : x86 Family 6 Model 23 Stepping 10, GenuineIntel
Virtual Machine : Java 1.6.0_13-b03 with Sun Microsystems Inc. Java HotSpot(TM) Client VM mixed mode
Window System : Version 5.1 (Build 2600: Service Pack 3)
Fault Count: 1
Abnormal termination:
Segmentation violation
I started in 2010a and moved to 2012a (both 32-bit) and the memory leaks only appear in 2012a. So something that was changed in-between the 2 versions is the cause of it. Simulink takes about twice as long to open in 12a as it did in 10a also.
We got a new computer, Windows 7/64-bit, and we did the same thing and there was no memory issue. The crash that I had above I think was a syntax change between versions in the s-functions that we’re using. Once I recompile those I think the crashing should go away, if what I think is wrong is actually wrong.
  2 comentarios
Jenn Lee
Jenn Lee el 23 de Jul. de 2012
I think he was asking what operating system are you using and what is its bit size

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 2 de Jul. de 2012
Editada: Walter Roberson el 2 de Jul. de 2012
You are using a 32 bit version of MATLAB on MS Windows, so you will run in to memory problems in some circumstances (but I would not expect crashes.)
Unfortunately I cannot find the reference posting for this at the moment. My memory is that in the 32 bit Windows version, MATLAB uses two different allocator methods depending on the size of the array being allocated, and that the MS Windows method used for the larger arrays, is not able to "give memory back" to the allocation pool under all circumstances.
  1 comentario
Walter Roberson
Walter Roberson el 2 de Jul. de 2012
I do not know enough about MATLAB internals (especially on MS Windows) to be able to tell you from the stack trace what is happening internally in MATLAB or how to fix the problem. Stack traces should go to MATLAB technical support.

Iniciar sesión para comentar.

Más respuestas (2)

Malcolm Lidierth
Malcolm Lidierth el 3 de Jul. de 2012
Editada: Malcolm Lidierth el 3 de Jul. de 2012
It looks like a mex-file is accessing MATLAB workspace memory but you are indexing using a pointer outside of the bounds of the array that has been allocated.
You see the exception sometimes but not always because its just chance whether the pointer will access a memory location that MATLAB is using and regards as valid.
Often, this turns up with an out-by-one errors running though an array. One that took me a while to figure out was pre-allocation using char(zeros...). The empty string space is reclaimed when you pass it on the RHS to a mex.

Jan el 2 de Jul. de 2012
Without doubt this is no usual behavior of Matlab. Please try to run only built-in code, e.g. benchmark and some examples. If this looks stable, the problem is most likely in user-defined code. Usually faulty C-Mex files cause such problems.
It could be a hardware problem also. Does other software run well on your system? Did you run a RAM- and CPU-test program already?


Más información sobre Application Deployment en Help Center y File Exchange.


Community Treasure Hunt

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

Start Hunting!

Translated by