I know that Java have its own garbage collection, but sometimes I want to delete the garbage manually. Is there any way to do the work like that? And considering that I have
It's not worth doing this manually, since the garbage collector will usually do a better job, and doing it yourself isn't likely going to make a noticeable difference in your application.
If you must, you can set the variable references to null, and call System.gc()
, and this will invoke the garbage collector manually.