Mem "leak" w/ long-running network apps?

Dave Brueck dave at pythonapocrypha.com
Fri Apr 18 17:56:19 CEST 2003


On Fri, 18 Apr 2003, Tim Peters wrote:

> > I'd notice that after my tests ran for a long time I'd stop them and
> > memory usage would drop down after awhile by a few megabytes, and upon
> > starting my tests again (without restarting my app) mem usage would drop
> > down some more but not all the way down and then it would gradually grow
> > again to a new high-water mark, so that overnight my process had hundreds
> > of MB of RAM.  With my recv-replacement I'm holding steady at about
> > 30 MB, which is normal.
>
> If you want to know more, scour your platform docs for whatever debug info
> your local malloc can deliver.

Okie dokie, I'll do that (I'm running on Linux).

> > Here's the function. I can get away with using a single large buffer for
> > all my receives because while the server is a mixture of threading and
> > poll-based, all the I/O happens sequentially in one thread against sockets
> > that are known to be ready for I/O.
>
> Heh.  That sounds regrettable, eventually <wink>.

It might be, eventually. :) For now though it's much faster and scales
much better than asyncore and the like, but I'm always looking to make it
better...

Thank you *so* much for taking the time to respond and for helping me
clean up my replacement function - I wasn't sure I really understood the
problem (or even why the fix worked), but it's encouraging to know I was
at least heading in the right general direction.

-Dave





More information about the Python-list mailing list