Python has a __dealloc__ method, which is called when the object is garbage collected. You can find examples by search_src.
On Jan 9, 2017 09:52, "John Cremona" <john.crem...@gmail.com> wrote: > In a reply to question 36225 at > https://ask.sagemath.org/question/36225/memory-leak-with-modular-symbols/ > (my reply was deleted by the system so you cannot read it) I offered > to try to help by asking here how to do somthign I don't know how to > do. > > When you do > > sage: E = EllipticCurve('11a1') > sage: M = E.modular_symbol() > > an instance of class ModularSymbolECLIB is created (as defined in > sage.schemes.elliptic_curves.ell_modular_symbols) which in turn > creates an instance of ECModularSymbol (as defined in sage/libs/eclib) > which in turn creates an ainstance of a C++ class in eclib which is a > C++ library. Currently there is no way the memory that uses up can be > released. I know that C++ classes have destructors which get called > when the objects go out of scope; presumably there is something > similar in python / cython? What would we need to do to get the > destructor called? > > Currently a loop such as > > DB = CremonaDatabase() > for N in range(1,10000): > Cs = DB.isogeny_classes(N) > for C in Cs: > E=EllipticCurve(C[0][0]) > phi=E.modular_symbol() > > uses up more and more memory even though after each run through the > innermost loop there is no data left in scope. > > John > > -- > You received this message because you are subscribed to the Google Groups > "sage-devel" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sage-devel+unsubscr...@googlegroups.com. > To post to this group, send email to sage-devel@googlegroups.com. > Visit this group at https://groups.google.com/group/sage-devel. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.