[sqlalchemy] Re: Sqlalchmey session memory is never released when used with pyramid.

2014-08-19 Thread Narendra L
Thank you Jonathan

I have created a standalone app and uploaded in github

*EXAMPLE APP:*
https://github.com/Narengowda/pyramid_sqlalchemy_app


*APP CONFIGURATION:*
Python version: Python 2.7.1
OS: Linux desktop-m 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 
2013 x86_64 x86_64 x86_64 GNU/Linux
Pyramid: pyramid-1.5
Sqlalchemy: SQLAlchemy-0.9.4

*LOGS:*
https://raw.githubusercontent.com/Narengowda/pyramid_sqlalchemy_app/master/README.md

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[sqlalchemy] Re: Sqlalchmey session memory is never released when used with pyramid.

2014-08-19 Thread Narendra L
Thank you Jonathan

I have created a standalone app and uploaded in github

*EXAMPLE APP:*
https://github.com/Narengowda/pyramid_sqlalchemy_app

*CONFIGURATION:*
Python version: Python 2.7.1
OS: Linux desktop-m 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 
2013 x86_64 x86_64 x86_64 GNU/Linux
Pyramid: pyramid-1.5
Sqlalchemy: SQLAlchemy-0.9.4

*APP MEMORY PROFILE LOGS:*
https://raw.githubusercontent.com/Narengowda/pyramid_sqlalchemy_app/master/README.md

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[sqlalchemy] Sqlalchmey session memory is never released when used with pyramid.

2014-08-15 Thread Narendra L


Actual question is here: 
http://stackoverflow.com/questions/25200475/sqlalchmey-memory-leak-how-to-free-memory

What measures should I take to cleanup old session objects? Isn't 
session.close() is sufficient?

or Is it something to do with pyramid?

Sqlalchmey 
setup:--def
 get_db(request):
maker = request.registry.dbmaker
session = maker()

@profile
def cleanup(request):
_session = request.db
if request.exception is not None:
_session.rollback()
else:
_session.commit()
_session.close()
# del _session # No memory released

request.add_finished_callback(cleanup)
return session
def main(global_config, **settings):
:
:
config.registry.dbmaker = sessionmaker(bind=engine)
config.add_request_method(get_db, name='db', reify=True)
:
:

Pyramid app request handler is like

@view_config(route_name='list_employees', renderer='json')def 
employees(request):
   session = request.db
   office = session.query(Office).get(1)
   employees = [x.name for x in office.employees]
   return employees

Now the problem is, In every request to list_employees the memory is 
growing. the size of increase in memory is almost equal to size of 
office.employees.

Debug:

request 1 starts with memory utilization = 10MB
request 1 ends with memory utilization = 18MB

request 2 starts with memory utilization = 18MB
request 2 ends with memory utilization = 26MB

request 3 starts with memory utilization = 26MB
request 3 ends with memory utilization = 34MB
 :
 :
   Grows eventually

employees = [x.name for x in office.employees]This is the line where about 
8-10MB memory utilized

To debug, I added *__del__* method in Employ and Office models, looks like 
they are deleting.

Also tried session.expunge(office), del office and gc.collect()

I am debugging memory consumption using 
https://pypi.python.org/pypi/memory_profiler Also I am using
https://pypi.python.org/pypi/transaction is other requests.

I have removed debug toolbar also

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.