Memory leak while running background processes?

28 views
Skip to first unread message

Kimmo

unread,
Jun 22, 2011, 4:06:25 AM6/22/11
to web2py-users

Hi,

I noticed a possible memory leak while moving our application to
production server.
Problem is simplified below as much as possible:

#--- db.py ---

db = DAL('mysql://root:root@localhost/memory_test', pool_size=0)
db.define_table('test_table',
SQLField('description'))

#--- end of file ---


#--- mem_test.py ---

while (True):
record = db.test_table[1]

#---- end of file ---

I inserted one record to test_table.

Background process is started:
python2.6 web2py.py -S Memory_test -M -N -R applications/Memory_test/
private/mem_test.py

Now if one monitors memory usage of the script is seems to steadily
consume more and more memory.
Guppy showed the same thing.

For test purposes I tried gc.collect() inside the while loop but it
did not help.
Also added db.commit() inside the loop just in case if that might do
the trick.


Am i completely missing something obvious or is this an actual bug?


Ubuntu 8.04
Web2py: Version 1.95.1 (2011-04-25 15:04:14)
Python2.6

- Kimmo

Massimo Di Pierro

unread,
Jun 22, 2011, 10:16:57 AM6/22/11
to web2py-users
Try adding this inside the loop:

db._timings = []

web2py logs all sql statements in db._timings This would cause a
memory leak but I would expect it to be negligible.
Reply all
Reply to author
Forward
0 new messages