[Cuis-dev] [DEFECT] Debugger leaves terminated processes
Gerald Klix
cuis.01 at klix.ch
Thu Oct 20 14:09:47 PDT 2022
I can provide additional information.
The leaks are caused by the debugger.
If you “do” the first part of the attached script,
you see that no leaks occur.
In a new image even the 100 UI processes, caused
by the 100 debugger get GCed after a while.
Really big processes, like the one with the 10M stack frames
tend to stay for ever.
I tried this trial/test on the big image.
The processes barely touched by the debuggers get GCed
after some time, the older ones stay.
Looks like the debugger using ContextPart's
debug protocol, causes some cycles hard to GC.
(Just my incompetent guess).
HTH,
Gerald
On 20.10.22 22:49, Jaromir Matas wrote:
> Hi Juan, Gerald,
>
> this is weird; some terminated processes get stuck in the system because they are being referenced which is why they don't get garbage collected (stating the obvious, I know); the question that puzzles me is why they are being referenced... which is unfortunately beyond my 'paygrade' (i.e. my skills) ;)
>
> you can see an example of such a "stuck" process here:
>
> Smalltalk garbageCollect.
> process _ ( Process allSubInstances select: [ :process | process isTerminated ] ) anyOne.
> ( Object allSubInstances select: [:obj | obj pointsTo: process] ) explore
>
> In most cases the newly terminated processes get garbage collected shortly (automatically) but some get stuck somehow (because referenced) and seem to stay stuck. I'm observing a similar behavior in older images from earlier this year so the most recent modification in isTerminated or the UI behavior should not be causing it.
>
> I'm not sure these 'stuck' terminated processes can cause memory issues Gerald observes but the truth is I don't understand the mechanism why they keep being referenced (and hence stuck).
>
> I hope someone could shed some light here or point in the right direction. I'd like to make sure the changes in termination I suggested are not causing somehow this behavior, and fix them if they do, of course.
>
> best,
> Jaromir
>
>
> --
>
> Jaromír Matas
>
>
>
> From: Gerald Klix<mailto:cuis.01 at klix.ch>
> Sent: Thursday, October 20, 2022 18:20
> To: cuis-dev at lists.cuis.st<mailto:cuis-dev at lists.cuis.st>; Juan Vuletich<mailto:juan at cuis.st>
> Cc: Jaromir Matas<mailto:mail at jaromir.net>
> Subject: [DEFECT] Debugger leaves terminated processes
>
> Hi all, Hi Juan,
>
> I think I found the cause of my huge images:
> The Debugger (or process termination)
> leaves terminated processes hanging around.
>
> First I saved the image before running the
> killer-Block (see the attached killit.st):
>
> -- snip --
> beforeLargeStack.image
> -rw-rw-r-- 1 bear bear 27M Okt 20 17:50 Haver6.0-5496-beforeLargeStack.image
> -- snap --
>
> Than I ran killit and simply closed the debugger window
> and saved the image:
>
> -- snip --
> -rw-rw-r-- 1 bear bear 1.9G Okt 20 17:51 Haver6.0-5496-afterLargeStack.image
> -- snap --
>
> From 27 megabytes to 1.9 gigabytes in 20 seconds,
> that's quite a feature, albeit a bad one.
>
> When I print all existing processes -- see diagnoseKillit.st -- I
> could see there are a lot of terminated processes hanging around.
>
> I did `self break` and closed the debugger: More terminated processes.
> Bad enough: `Smalltalk garbageCollect` does not help.
>
> The first part of RunningProcesses.txt is the transcript
> output after running the killer-block.
> (There are already some terminated processes, because I used
> image to implement the fixes, I just posted).
> The second part is transcript output after one `self break`;
> I didn't check exactly, but there are more terminated processes.
>
>
> Best Regards,
>
> Gerald
>
>
-------------- next part --------------
"First part, doit til second part"
terminatedProcessCounter _ [ Process allSubInstances count: [ :process | process isTerminated ] ].
'Simple fork' print.
terminatedProcessCounter value print.
1 to: 100 do: [ :count | [ 100 factorial ] fork ].
terminatedProcessCounter value print.
'Handled exception' print.
1 to: 100 do: [ :count | [ self halt ] on: Halt do: [] ].
terminatedProcessCounter value print.
'Debugger creation' print.
terminatedProcessCounter value print.
1 to: 100 do: [ :count | [ 1 / 0 ] fork ].
"Doit after all debuggers are open"
'Debugger close' print.
Smalltalk garbageCollect.
DebuggerWindow closeAllDebuggers.
terminatedProcessCounter value print.
More information about the Cuis-dev
mailing list