File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes byte array and garbage collection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "byte array and garbage collection" Watch "byte array and garbage collection" New topic

byte array and garbage collection

Pho Tek
Ranch Hand

Joined: Nov 05, 2000
Posts: 761

My program spawns many threads. Each thread will allocate a byte array of size 100,000. Do I need to null the array within each worker thread as they are about to die ?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14435

An object becomes eligible for garbage collection when there is no live thread that holds a reference to the object.

Setting variables to null in a thread that's going to stop immediately after that doesn't help anything for garbage collection.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
I agree. Here's the link:
subject: byte array and garbage collection