From: Danny C. <dan...@gm...> - 2008-01-30 16:36:00
|
Matthias, I still get the same false warning for the simple testcase. However, some other code that essentially does the same thing (returns a heap allocated array) produces weird results. I have %typemap(newfree) u_char * "delete [] ($1);"; defined. If I use %newobject obj::get_uchar; I dont get the error message, however, the memory foot print keeps increasing, indicating that the delete is not called. And If I use %newobject get_uchar; w/o the class qualifier I get the error message saying that a mem leak has been detected. But the memory foot print does not increase, indicating NO leak. I dont know what gives? Any insight would be helpful. thanks, On Jan 29, 2008 7:13 PM, Nitro <ni...@dr...> wrote: > Am 29.01.2008, 23:34 Uhr, schrieb Danny Crasto <dan...@gm...>: > > > I have a C++ member function that returns a heap allocated array > > pointer u_char* > > > > u_char* obj::get_uchar(int size){ return new u_char[size]} > > > > I specify in the interface file > > %typemap(newfree) u_char * "delete [] ($1);"; > > %newobject get_uchar; > > > > I call this function in an infinite loop. The memory usage (in top) is > > constant. So there is no leak. However, python says > > "swig/python detected a memory leak of type 'u_char *', no destructor > > found" > > > > how do I get rid of this message? Or am I doing something wrong? > > Not sure, doesn't this have to be > > %newobject obj::get_uchar; > > ? > > -Matthias > Matthias, I get the same thing either way. -- - danny "for(i=0;i<1000000;i++) {;} //speed up loop, drop a zero" |