Is a dead thread a memory leak?

Is it a dead thread threatening to use memoirs? will he end up with GC?

+4
source share
4 answers

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

The threat to memory usage ... it depends on how much memory you use in it - and how many links to other instances of objects (lists, Hashtables, ...). This is exactly the same threat to memory usage as any other type of object.

+7
source

Obviously, if your code still has a link, the stream object still exists, it cannot be restarted, but it can still be used with a java object (sorry if this was too obvious, it is best to eliminate this first ;-))

The same thing happened here.

http://www.coderanch.com/t/531074/threads/java/dead-thread-threat-memory-leak

+1
source

Setting the thread object to null should guarantee the GC for the dead thread object.

+1
source

Just put all the resources you no longer use to put it in null better, and then sorry. GC will choose this.

+1
source

Source: https://habr.com/ru/post/1346899/


All Articles