I'm trying to lower the memory use of an app and have some general 
questions about how memory is used in DAL selects:


   1. Am I right that the memory used while performing the select isn't 
   released right away, even if the select isn't assigned to a variable? 
   2. I'm aware of iterselect. Am I right that with iterselect the memory 
   used is just enough to store one row of data (instead of the whole selected 
   set)?
   3. Does this mean that, generally, you want to perform as few separate 
   selects as possible, unless you can use iterselect?
   4. Selects seem to occupy a significant amount of memory, even when the 
   result set is only one row. Is the memory use for the select determined by 
   the table size or the result size?

Here's an example of the kind of situation I'm working with. I'm using a 
list comprehension to loop through a list, performing a select in each loop:

    p_here = [p for p in cpaths if loc_id in db.steps[int(p['steps'][0])].
locations]


When I run a memory profiler, this line results in over 1MB of memory being 
occupied, and that memory isn't released for at least several minutes. The 
table "steps" has about 3000 rows, so it's not enormous. The result for 
each select is a single row and doesn't include a huge amount of data (a 
few strings, ints, etc.). The "cpaths" list might have 50 or so items. So 
is the memory issue emerging because (a) the memory use for each select is 
determined by the table size, and (b) memory is being occupied (and not 
released) separately for each iteration of the loop? Is there a way to 
rewrite this so that it uses less memory?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/d2665636-2694-4262-b3ad-441e1c1f695a%40googlegroups.com.

Reply via email to