Singular https://www.singular.uni-kl.de/forum/ |
|
Libsingular memory management (memory leak?) https://www.singular.uni-kl.de/forum/viewtopic.php?f=10&t=2712 |
Page 1 of 1 |
Author: | greka [ Tue Feb 06, 2018 11:57 pm ] |
Post subject: | Libsingular memory management (memory leak?) |
I'm struggling with a memory clean up/possible memory leak problem. Calling simple code like Code: ring r = ...; ideal i = ...; slimgb(i); kill r; builds up (variable) memory (I'm checking memory(0) and also direct system output coincides with this observation), although I would expect that after "kill r" everything is cleaned up (there are no further variables and processes defined). I realized it since I'm calling code like that a lot of times inside the same (c++) session. It seems to me that memory is lost whenever something is printed (output and info/warning messages). My question though is two-fold: Is this actually a bug in the code or I'm I forgetting to clean up something? I'm mainly interested to have this properly working through the c++ interface. (I'm using interpreter functions directly from within c++, like iiAllStart), the same memory loss happens also happens when called from the singular binary. Or is there a way to reset the whole interpreter environment from within c++ without a full restart? (If you're interested: I'm actually building a simple Singular interface for Mathematica via its LibraryLink function to have fast interaction with Singular. Everything except from this memory problem works like a beauty.) |
Author: | hannes [ Wed Feb 07, 2018 4:00 pm ] |
Post subject: | Re: Libsingular memory management (memory leak?) |
There several things still taking memory legally: - standard.lib is always loaded (see listvar(proc)) - the kernel introduces some variables (Top, ZZ, QQ, etc.) - polynomials rings over ZZ/p (for p<2^15) create 2 tables of size 2*p bytes which is cached for the next ring creation - the last output is cached (to be accessed via _) - this cache is cleared, if the value depends on a ring and the ring is killed. |
Author: | greka [ Wed Feb 07, 2018 6:00 pm ] |
Post subject: | Re: Libsingular memory management (memory leak?) |
If I understand correctly theses things don't grow indefinitely (i.e. once they are initialized they stay more or less the same size depending on their current value), so that's not a problem for me. To illustrate where I have memory building up consider the following code: Code: ring r = (0,a), (x), dp; ideal i = x, x; slimgb(i); kill r; memory(0); Running this piece of code several times inside the same session expands the used memory after every repetition. Since I run code like that a lot of times in the same session I eventually run out of memory. One observation that I made is that there is no memory increase if I drop the constant 'a' in the ring definition. I also checked out other examples and I couldn't not find a pattern in which cases there is memory building up. |
Author: | hannes [ Thu Feb 08, 2018 5:05 pm ] |
Post subject: | Re: Libsingular memory management (memory leak?) |
The example you provide does not have a memory leak in the current (development) version of Singular |
Author: | greka [ Thu Feb 08, 2018 8:25 pm ] |
Post subject: | Re: Libsingular memory management (memory leak?) |
Awesome, I just pulled the newest version and it indeed works nicely. Thanks a lot! |
Page 1 of 1 | All times are UTC + 1 hour [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |