[Orbit-python-list] Almost there (was: memory leak)
Status: Inactive
Brought to you by:
tack
From: Roland M. <ma...@ec...> - 2000-08-12 06:06:49
|
Jason Tackaberry (2000-08-10 07:17:46 -0400) : > > I attach a simple server, client and IDL file. They demonstrate a > > memory leak somewhere: the server starts at about 2.5 kb and grows to > > On second thought, your idl isn't using any structs or unions, which is > where the leaks I've identified are. You may want to look at leaks I've > flagged in server.c and client.c. I'm pretty sure I'm leaking memory > with opd->parameters._buffer but I'm not sure how to free up that > memory. (I tried various things that result in a segfault.) I'll poke > around this some more, but I'd appreciate it if you could look into it > too. Well, I'm almost there. I spent the last two days (nights, actually) in src/server.c, and I fiddled in it a bit. Here are my results. I think the leak you mention in src/server.c is not real (or, it is not the only one). Without doing anything with opd, I manage to suppress the memory leak in some cases. I guess g_free takes care of things for you, but I wouldn't stake my life on it. We have four types of calls: the _get_*, the _set_*, the other methods with parameters, and the other methods without parameters. Using the (included) updated test-case suite, Orbit-Python leaks memory for all four of them. I tried many things, adding and removing Py_INCREF's and Py_DECREF's here and there, and I got a great many segfaults too :-) But in the end, I gathered that the server needed a bit of clarification, since the 'result' variable is used, overwritten, Py_INCREF'ed and Py_DECREF'ed too many times. So I cleaned the code a bit, added the 'fresult' variable, which contains the result object we'll have to free at the end, and Py_DECREF'ed it. My results: the memory leak is dead in three of the four aforementioned cases, namely the _get_* call and the method calls, with and without parameters. It remains unchanged as for the _set_* calls, though (same pace of leak). I include my patch to the current CVS version, as well as the updated test suite. I'll also upload the patch to Sourceforge in a few minutes. I'm not quite sure of myself, so the more people use it and crash-test it, the more certain I'll be that my patch broke things or not. If it does, please tell me! I depend on feedback here... Also, I'll continue investigating on the _set_* case, but I'm getting blind at looking at the lines 105-115 and 125-130. I'm almost sure the bug is right there, though. May the Force be with us for the last (?) line, Roland. |