Python/C - Memory-Management

Jonathan Epstein Jonathan_Epstein at nih.gov
Thu Mar 7 11:42:49 EST 2002


I have a similar problem with SWIG, which I haven't gone back to in a while.

When I do get back to it, though, I plan to either purchase a license for
Rational Purify, or just see how much I can accomplish using a free trial
license.

I believe that Purify runs on Windoze, Solaris and Irix.  If one or more of
these platforms are available to you, I suggest giving it a try.

It's pretty expensive, but about half the price on Windoze ($750?) as I
recall.

http://www.purify.com/products/purify_unix/index.jsp
http://www.purify.com/products/purify_nt/index.jsp

Oh, and please let me know how effective this is if you try it ;-)

-Jonathan

"Heiko Wolf" <heiko.wolf at dlr.de> wrote in message
news:d013da35.0203070154.64411e59 at posting.google.com...
> Hi there,
>
> I've got some C-functions that shall be adressed from Python. Thats no
> problem, thanks to SWIG.
>
> But now there is a problem about the memory management: One of the
> C-functions allocates memory for all the other functions. In C it
> works that way:
>
> static char *memory = NULL;
>
> int init_mem (void)
> {
>
> memory = (char *)malloc(sizeof(char) * 1000);
> }
>
> int free_mem (void)
> {
>
> free(memory);
> }
>
> If another function calls init_mem, it can use memory until free_mem
> is called... I want to do the same now in Python, but it seems as if
> the static memory isnt kept somewhere? When I try accessing it, I get
> a Segmentation Fault... Any suggestions?
>
> Cheers, Heiko





More information about the Python-list mailing list