My web2py instance gradually eats memory, during day the consumption
grows up to several gigs, so I have to restart often. According to guppy
most of memory is occupied by gluon.dal.Field and other classes of dal:
Partition of a set of 3231760 objects. Total size = 443724152 bytes.
Index Count % Size % Cumulative % Kind
0 113419 4 189636568 43 189636568 43 dict of gluon.dal.Field
1 1324208 41 80561096 18 270197664 61 str
2 328642 10 15982732 4 286180396 64 tuple
3 26637 1 13851240 3 300031636 68 dict of
gluon.validators.IS_IN_DB
4 98796 3 13436256 3 313467892 71 dict of gluon.dal.Set
5 20042 1 13344464 3 326812356 74 dict (no owner)
6 8199 0 11860464 3 338672820 76 gluon.dal.Row
7 16615 1 11482224 3 350155044 79 gluon.dal.Table
8 63682 2 8660752 2 358815796 81 dict of gluon.dal.Query
9 137779 4 7363776 2 366179572 83 list
<2282 more rows. Type e.g. '_.more' to view.>
The proportion is relatively stable. It seems that model definition
remains in memory after each request. It is probably caused by a weird
reference, but I'm not sure how to track it. Please do you have any ideas?
Thanks :)
David
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAk0VN9gACgkQ3oCkkciamVFHHwCfWiIkmrH9buBYA/7HvgIbz+mR
ei0AniZ0UYwZtj9zagp2sx/IawmBE2iA
=9cqX
-----END PGP SIGNATURE-----
This is due to the built in rocket server (it is not ment for production). If you use Apache with mod_wsgi this will not happen.
I think you are right. It is highly probable that my app is leaking
somehow. I do not cache dal objects directly and I use finite set of
indentifiers for cached objects, but it is possible that some of my
objects reference dal objects in an unwanted way, leading to some kind
of circular references which prevent garbage collection. It is not easy
to identify where exactly is the problem rooted, because my model is
quite complex (more than 100 tables, highly interlinked, etc.) and I
cache business objects built above DAL a lot. Maybe I'll use some tool
to examine the references between objects in memory (objgraph?).
So, I agree that there is probably no leak directly in web2py or Rocket
and uWSGI does not bring cure for the memory leak disease causation, but
it removes the symptoms, which makes me satisfied for now. The new setup
is also more stable. With Rocket my web2py freezed every couple of hours
(http://groups.google.com/group/web2py/browse_thread/thread/bd4f6e9f20d1a5aa)
and I had to monitor its state and force restarts whenever it happened.
Now it either freezes no more or Cherokee restarts uwsgi behind the
scenes whenever necessary. :)
David
- --
David Zejda, Open-IT cz
web development & services
http://www.o-it.info
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAk0YZeMACgkQ3oCkkciamVFgdgCfczag6uRCsadFl+TtTBj+SDgV
BokAoLfKc4Caslc0QISWt1fXf6lAhCBv
=+XpP
-----END PGP SIGNATURE-----
I should also mention that I recently updated my code to use multiple controllers.
On Monday, February 6, 2017 at 7:53:20 AM UTC-8, MarkEdson AtWork wrote:Update,I ran the sample code I placed in this post over the weekend and it ended up consuming 1.8GB before python stopped functioning.I am running pyDAL (17.1) with a stable web2py release.Is this the built-in Rocket server issue I have run into?
I found a similar issue with a db.py module with code like this in it...from gluon.packages.dal.pydal import DAL, Fielddb = DAL("sqlite://storage.sqlite")db.define_table("test",Field("myid", default=DEFAULT_VALUE, length=15),Field("name", default=DEFAULT_VALUE, length=15),Field("code", default=DEFAULT_VALUE, length=2),)