From: SourceForge.net <no...@so...> - 2011-04-25 23:30:54
|
Bugs item #1501284, was opened at 2006-06-05 15:27 Message generated for change (Comment added) made by sswamida You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101645&aid=1501284&group_id=1645 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: python Group: None Status: Closed Resolution: Wont Fix Priority: 5 Private: No Submitted By: S Joshua Swamidass (sswamida) Assigned to: Marcelo Matus (marcelomatus) Summary: OUPUT typemap --> python memory leak Initial Comment: using the output typemap with Swig 1.3.24, Python 2.4 on Linux causes a memory leak. For example, consider a swig declaration: void func(double *OUTPUT, double *OUTPUT); for the following C function: void func(double *out1,double *out2) { *out1=1324; *out2=24; } This function ca be used as expected: >>> from swigmodule import func >>> func() (1324.0, 24.0) However it produces a memory leak revealed by watching memory usage with repeated iteration: >>> while True: ... func() -----> rapidly increased memory usage. Please advise. ---------------------------------------------------------------------- Comment By: S Joshua Swamidass (sswamida) Date: 2011-04-25 16:30 Message: One more quick point. If you swig the code I put up there, and run while True: func() Then this will increase memory to the point of causing a seg fault. ---------------------------------------------------------------------- Comment By: S Joshua Swamidass (sswamida) Date: 2011-04-25 16:28 Message: Hello szager, This is not a problem with python. Your code is not memory efficient. A better version: for i in xrange(10000000): i + 1 Range generates the full list first in memory before performing the iteration. Xrange does not and uses constant memory. This is clearly a bug in the swig template. The workaround is to add in code to free out1 and out2 our avoid the template altogether. But this is clearly a memory leak error in swig's template. ---------------------------------------------------------------------- Comment By: szager (szager) Date: 2011-04-25 15:55 Message: I believe this is a characteristic of python, not SWIG. When I run this code: for i in range(10000000): i + 1 ... I get the essentially the same memory profile as with your example. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101645&aid=1501284&group_id=1645 |