1

i'm developing a python 2.6 (tested both on 2.6.5 and 2.6.6) application which is going to run as a daemon on my VPS. During some tests, i've found out that the app itself it's consuming (during its sleep time, so no activities or allocations whatsoever) about 37.53MB of memory. I i've spent the last few hours optimizing the code to reduce the app memory footprint but i miserably failed XD

I'm using this line of bash code to get the memory used by my app:

ps u -p $(pidof python) | awk 'NR > 1 {nm += $5} END {print nm * 1024}' *(Yes, im sure i have only that one python instance running ;))* 

So, just to be sure i was not goin to waste my time, i ran just a python interpreter session (no script, no args, no modules loaded) and with the same script i use to get the memory consumed by it ... you know what?

It's almost the same as my entire app!

So, there's any way to reduce the python interpreter memory footprint? I even tried to set the gc threshold to 3 for the first generation and then call gc.collect() in safe places of my app ... but nothing changed :(

1
  • This blog post describes the python mem footprint for different data structures ... it can help minimize your daemon's footprint Commented Jun 16, 2013 at 16:57

1 Answer 1

1

Are you sure you are not reading the Python virtual memory?

Python here consumes 3.4MB of private memory.

Sign up to request clarification or add additional context in comments.

3 Comments

Well that bash script is taken from Munin, so i hope|think is correct ... any way to verify this ?
The fifth ( $5 in awk ) field is VSZ in the ps u -p <pid> output ... what is its meaning?
i think i should fix this with $6 taking RSS instead of VSZ, right? :P

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.