Subs Function Memory Leak
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi, I'm running a function (for discussion purposes I'll call it myfun.m) which utilizes both "solve()" and "subs()" function. Multiple runs of the myfun causes longer and longer execution times. I believe this issue is some sort of memory leak. If I close out of Matlab, open it back up, and execute myfun, it runs at the normal speed. If I continue executing it over and over it then begins to slow down. I was running 2007, but I'm upgrading to 2010. Has this problem been fixed? Is there some sort of clear function I can use that preserves my variables but clears whatever objects are being generated by subs or solve?
2 comentarios
Jan
el 20 de Jul. de 2011
Please post any details. There is no known memory leak in SOLVE and SUBS. If there is a memory leak, it could be observed by inspecting the growing memory consumed Matlab. So you observe this?
Respuesta aceptada
Walter Roberson
el 20 de Jul. de 2011
solve() uses mupad which has its own memory area. Try using
reset(symengine)
1 comentario
Walter Roberson
el 20 de Jul. de 2011
Your code is somewhat long and complicated to go through.
If I were to go through it myself, I would be asking whether perhaps entire portions of it could be written symbolically and solve()'d, and then matlabFunction() used to convert that to MATLAB code that you could then just call with the actual numeric values.
Más respuestas (1)
Michael Feeney
el 20 de Jul. de 2011
4 comentarios
Walter Roberson
el 20 de Jul. de 2011
eval() invokes the full matlab parser and JIT and threaded interpreter, and is thus a heavy-weight method of dealing with the situation.
subs(solve(...)) will look for variables in the result of solve() and will, if possible, replace them with values from the current workspace, and then will do whatever further calculations are practical. That should leave you with a symbolic number or a symbolic formula involving only constants; double() will then convert that symbolic number or constant symbolic formula in to a MATLAB-level double-precision number. The symbolic engine will handle this efficiently.
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!