From: Chris Rebert on
On Mon, Jul 19, 2010 at 6:30 PM, Vishal Rana <ranavishal(a)gmail.com> wrote:
> Hi,
> In my web application (Django) I call a function for some request which
> loads like 500 MB data from the database uses it to do some calculation and
> stores the output in disk. I just wonder even after this request is served
> the apache / python process is still shows using that 500 MB, why is it so?
> Can't I release that memory?

http://effbot.org/pyfaq/why-doesnt-python-release-the-memory-when-i-delete-a-large-object.htm

There are multiple layers of memory allocation involved. To avoid
thrashing+fragmentation and to improve efficiency, free memory is not
always immediately returned to the operating system. Example: If your
problem involved calling your 500MB function twice, free-ing after the
first call and then immediately re-allocating another 500MB of memory
for the second call would waste time.

Cheers,
Chris
--
http://blog.rebertia.com
From: Christian Heimes on
> In my web application (Django) I call a function for some request which
> loads like 500 MB data from the database uses it to do some calculation and
> stores the output in disk. I just wonder even after this request is served
> the apache / python process is still shows using that 500 MB, why is it so?
> Can't I release that memory?

Are you talking about resident or virtual memory here?

From: Christian Heimes on
Am 20.07.2010 17:50, schrieb Vishal Rana:
> Hi Christian,
>
> I am not sure which one is used in this case, I use htop to see the memory
> used by apache / python.

In its default configuration htop reports three different types of
memory usage: virt, res and shr (virtual, resident and shared memory).
Which of them stays at 500 MB?

Christian