Re: Tracking down memory usage (leak?) in Pike program
Chris Angelico <[email protected]>
| Newsgroups | gmane.comp.lang.pike.user |
|---|---|
| Message-ID | <CAPTjJmo4dmacDY4JMJ=YWLOPrQ1r8SkqMFr9BqReQyxz1G0qcQ@mail.gmail.com> |
On Wed, Jul 20, 2016 at 6:24 AM, Fredrik Hubinette <[email protected]> wrote: > I notice that num_objects is WAY smaller in your newly started program. > That means that your program leaks objects somehow. I suspect that those > objects also have some external data, such as UI elements or events > associated with them, which would explain why you don't see all the data in > object_bytes. Ah, that would probably explain it. That almost certainly means it's GTK2 objects that I'm leaking. Okay, so that's what I need to track down... > Of course, by "leaked" I mean that they are somehow still > referenced, but not on the screen. This can happen if UI elements have > callbacks to themselves for instance. It's possible that adding descruct() > calls when you remove ui elements could resolve this problem. Interesting. Okay. I do quite a bit of opening and closing windows (including one notable one with roughly five million widgets on it - it's a ten-tab Notebook for a character sheet, lots of GTK2.Entry fields and stuff), so if those are getting leaked, that would definitely explain it. Although my regular closewindow() function (which gets called for the delete_event and any Close buttons and stuff) does call mainwindow->destroy(), so I'd have thought that would clean it all up. I'll slap in a destruct(mainwindow) after that and see what happens. > The next step is to walk all the objects in memory, get their programs and > see how many instances you have of each program. Debug.pp_object_usage() says this: Object Clones Memory Loc ___GTK2.Label 23800 1.6M pgtk.c:5249 ___GTK2.GdkGC 11318 795.8k pgtk.c:6284 I've no idea how many *active* Labels there are, but it sure ain't twenty three thousand, and GdkGCs ought to be extremely short-lived, so I think I've found the leaks. A freshly-invoked Gypsum has 48 labels, quickly rising to 300 within the first minute of operation. Thanks for the pointers! Now I can start tracking down where these Labels are getting created and why. (I've a fairly good idea about the GCs.) ChrisA