Il giorno venerdì 15 dicembre 2017 16:28:29 UTC+1, Dima Pasechnik ha scritto: > > it need not happen, unless you explicitly trigger garbage collection > > import gc > gc.collect() > > see https://docs.python.org/2/library/gc.html for details > Thanks! Now I know why the first function needed so much memory. I did not trigger garbage collection but it seems enabled by default (at least this is the case for all Sage's kernels installed in CoCalc). I do not see why it should be enabled by default. Unfortunately this does not solve the problem with the above function "ex_f", even if it does not return anything it is still "consuming" memory. Could be that the "f.factor()" output is stored in the polynomial's object and then the object itself is not erased/overwritten when a new polynomial is generated? Or a simpler solution could be that f.factor() calls Singular and there the garbage collector is enabled.
Il giorno venerdì 15 dicembre 2017 16:47:02 UTC+1, Nils Bruin ha scritto: And undoubtedly it did (a list of integers has no circular references, so > it can be deleted just based on reference counts), but obtaining memory > from and returning memory to the operating system is an expensive > operation, so python is probably reluctant to do so. > > get_memory_usage only reports how much memory is allocated to the python > process, not how much of it python is actually considering as in use. So there is a discrepancy between the real amount of memory in use and the one allocated but, when I run a process, my hardware limits the allocated one. So, for instance, I can evaluate ex_f(p) just for very small values of p even if the real amount of memory in use is almost zero for any p. -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.