[mod_python] memory error

Webb Sprague webb.sprague at gmail.com
Fri Sep 28 12:00:20 EDT 2007


Hi Mike

I will give another look, but I don't think there are any cyclic
references - I create 1000's of scipy matrices and try to store them
in a database, so I think it really is memory problems.  It also works
fine with smaller matrices, and memory is freed after the process is
over, so it isn't a leak (I don't think).

Thanks for the advice though.

-W

On 9/28/07, Mike Looijmans <nlv11281 at natlab.research.philips.com> wrote:
> If Python does not release memory immediately, it usually means there's a cyclic reference. Try to
> break the cycle by removing as much references as possible.
>
> e.g.
>
> a = A()
> b = B()
>
> a.b = b
> b.a = b
>
> Causes a "cycle". The garbage collector will pick these up at some other time.
> To release earlier, assign None or delete the reference like:
> a.b = None
> or even:
> del a.b
>
> It usually helps to monitor big objects by putting a "print" statement in their __init__ and __del__
> method.
>
>
> Mike Looijmans
> Philips Natlab / Topic Automation
>
>
> Webb Sprague wrote:
> > Could anyone recommend a method for profiling memory usage in a
> > mod_python application?
> >
> > My application creates lots and lots of scipy matrices, and then
> > pickles them, and then stores them in a database.  If I do too many
> > runs I get a memory error when I try to insert them, but I also get
> > lots of swapping before that.  I could delete some of these arrays,
> > but I would like to figure out where the biggest problems are (because
> > I would prefer to store everything).
> >
> > I would be happy to analyze a core dump too.
>
>
>
>


More information about the Mod_python mailing list