|
SWIG - Memory leak: msg#00174programming.swig
Hi there, I have a problem with a very simple extended swig function. I'll try to make this as short as possible so here it is: In my C Code, I define the following: typedef float REAL32; I want to export a C function to swig that has the following prototype: void somefunction(REAL32 param1); Lets say my module is called : mymodule, in python I cant call write the following code: import mymodule mymodule.somefunction(1.0) because it is telling me that I pass the wrong argument type. So I created a simple typecasting function that maps a float to a REAL32, even if it is casting to the same type (float = REAL32), So I add the following in the %inline section of my mymodule.i file REAL32 toREAL32(float value) { return (REAL32)value; } My Python function is an iterate function. It is called many times; in my function I do the following: def mypythonfunction(): number = mymodule.toREAL32(1.2) return "ok" If this function is called many times (thousands of), the program will begin to leak and In approximatively 2 mins, It eats 10Megs of ram. The weird thing is that if I define my typecasting function as the following: float toREAL32(float value) { return (float)value; } or float toREAL32(float value) { return value; } there is no memory leak at all. And the C meaning of this function is the same as the 1st one since I have a typedef on REAL32 for float. My code is called From a C++ program so the "hierarchy" is the following: C++ program | V Python function | V C toREAL32 function Is it because I do something wrong? Is there another way of doing this ? Thanks, Mathieu Tremblay mtremblay@xxxxxxxxxxxxx _______________________________________________ Swig maillist - Swig@xxxxxxxxxxxxxxx http://mailman.cs.uchicago.edu/mailman/listinfo/swig |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: swig and perl580 and sun solaris compiler 5.3: 00174, David Fletcher |
|---|---|
| Next by Date: | newbie problem with python lists as c-function arguments: 00174, Marcus Stojek |
| Previous by Thread: | RE: SELL FLASH MEMORY USB DRIVEi: 00174, iywuot |
| Next by Thread: | SWIG - Memory leak: 00174, David Beazley |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |