Delete unused variable's memory in java

前端 未结 8 610
不知归路
不知归路 2020-12-28 12:19

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

8条回答
  •  温柔的废话
    2020-12-28 13:14

    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.

提交回复
热议问题