On Jun 12, 4:43 am, Graham Dumpleton <graham.dumple...@gmail.com>
wrote:
>
> On Jun 12, 11:51 am, Miles <boo...@gmail.com> wrote:
> > If someone has an idea how to get memory usage at about the same with
> > lower cpu cost than a full GC every request, please tell.
>
> In Python, garbage collecting is not real garbage collection like
> other systems. Primarily, Python uses reference counting on objects
> and so is able to reclaim memory as soon as last reference is gone.
> The problem, and where GC kicks in in Python, is where there are
> object reference count loops. That is, where a network of objects have
> mutual references to each other.
>
> If you can, perhaps try and determine what objects it is that the GC
> is having to deal with. In some cases the design of objects can be
> changed to avoid the GC needing to kick in to reclaim them.
>
> Graham

Almost everything refers to and from a certain page variable, which
contains the state of the whole page, with lists to in memory and
database objects.

Page: contains a list of actors (read: players / creatures). Contains
many other variables, like current report (read: url).
Actor: contains a reference to page, so actor.link() knows where to
point the a href to.

And that's the case for many other objects, basically anything that
needs to dereference some id to an object.

We could rewrite everything from OO to page.actor_get_link(actor), but
in templates where the convention for tags / macros (jinja2 \o/) is
only pass what it really needs to know, passing page around on every
call will make the code really ugly to work with.


Unrelated: I found out about gc.set_debug(gc.DEBUG_STATS); It's pretty
useful, but:

1. What's the idea of printing time.time() to stderr like 3 million
times. And elapsed. It does that for every ref cleared?!
2. Auto collect triggers gen 2 collection frequently, live object
count is exactly the same as manual collection, but memory used
doesn't drop. Weird. Sample line: [Fri Jun 12 04:20:07 2009] [error]
gc: done, 8193 unreachable, 0 uncollectable.
3. gc.gc() gives 8193 as well, but it *does* get the RSS down to
acceptable levels.

Bug? I've glanced around in gcmodule.c casually, but couldn't find
anything wrong with that. It might be some weird interaction with
other code, but as a complete newbie to Python internals, I probably
can't track that down.

Miles
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to