Hey Tim,
So this question is a bit complicated and goes a bit beyond web.py (and
even python). The short answer is probably that linux is simply leaving
the memory with that process until something else needs it (the python
interpreter could be doing this as well).
if you do a "free -m", you will see a "cached" column. If this number is >
0, your system has plenty of free memory available for actual programs.
As a test, use "Apache Benchmark" to hit your application 5000 times or so.
My guess is that you will not see the memory usage increase by 5000
(indicating a memory leak).
Also, you could remove web.py and run a simple raw WSGI app, for example.
def application(environ, start_response):
status = '200 OK'
output = 'Hello World!'
a = list(range(10000000))
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
I would recommend looking into using nginx / UWSGI to host your web.py
applications. I've used apache and mod_wsgi for a while now, but after
recently switching to nginx / UWSGI I will not be going back.
On Tue, Jan 20, 2015 at 7:52 AM, Tim Sheerman-Chase <[email protected]>
wrote:
>
> Hi,
>
> When I allocate a significant amount of memory within a GET method, apache
> does not release it back to the system, as far as I can tell. I am using *top
> *and *free *to evaluate memory usage. This memory might be for caching
> within apache. I am using apache 2.4.7-1ubuntu4.1, mod_wsgi
> 3.4-4ubuntu2.1.14.04.2 and web.py 0.37.
>
> My script is simply:
>
>
> import web, os, sys
> web.config.debug = False
>
> class Test(object):
> def GET(self):
> a = list(range(10000000))
> return "done"
>
>
> #Specifies the URLs that are provided by this web.py server
>
> urls = (
> '/', 'Test',
>
> )
>
> #Create object to handle http request
> app = web.application(urls, globals())
>
> application = app.wsgifunc()
>
> Should I expect the memory to be released after the page has been served?
> Is there some config setting that I don't know about?
>
> I have tried running apache in embedded and daemon mode but appear to be
> similar in they don't return to their original memory usage.
>
> Tim
>
> --
> You received this message because you are subscribed to the Google Groups
> "web.py" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/webpy.
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"web.py" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/webpy.
For more options, visit https://groups.google.com/d/optout.