Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is a dead thread a threat to memory leak?

Is a dead thread a threat to memory usage? Will it eventually get collected by the GC?

like image 220
developer Avatar asked Dec 28 '22 22:12

developer


1 Answers

A dead thread, as any other object, will be collected by the GC if cannot be reached by any references to it. Setting ALL variables that point to it to null should make it available for collection by the GC.

A threat to memory usage ... it depends on how much memory you're using in it - and how many references to other object instances (Lists, Hashtables, ...). It's exactly the same threat to memory usage as any other type of object.

like image 185
Manuel Salvadores Avatar answered Jan 13 '23 18:01

Manuel Salvadores