On Thursday, October 1, 2015 at 1:57:33 AM UTC-5, Jori Mäntysalo wrote: > > On Wed, 30 Sep 2015, Travis Scrimshaw wrote: > > > Actually, it's not surprising that your seeing an increase in memory > usage. > > Note P7 is a list with strong references to each of the posets, so they > > cannot be garbage collected. Since the results of meet_matrix are > cached, > > you increase your memory usage. > > I am not sure if I understood. Why is meet_matrix re-calculated or > re-copied in memory? > > It's not. By having a *list* of all of the posets, you are not allowing the *posets* to be garbage collected, and hence, the (cached) meet matrix associated to each of them.
> Compare that with this: > > > > sage: P7 = Posets(7) > > . . . > > sage: for P in P7: > > . . . > > ....: gc.collect() > > > > The call to the garbage collector is not necessary, but you see that the > > memory usage is bounded. > > Without gc.collect() it still eats memory. Of course it might trigger > garbage collection when memory usage is big enought. > Notice that P7 is not a list, but a class with an iterator. > > But in any case, there is no way to run some codes that iterate over all > posets of size n when n is too big. This is because there is no way to ask > UniqueRepresentation to release memory. Or --- will gc.collect() do this > also? > > It does release memory when there are no *strong* references back to the object. A strong reference is would be something like P = Poset({}) or L = [Poset({})], a top-level variable that points to the object in some capacity (like being an element in a list). Simon, Do you know off-hand if is it safe to dynamically add in a class to the MRO of a subclass of UniqueRepresentation? Best, Travis -- 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 http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.