Smart Garbage Collection?

后端 未结 6 1716
别那么骄傲
别那么骄傲 2021-01-20 17:24

You can garbage collect in Java simply by calling System.gc() but sometimes this \"stalls\" the application. Is it a bad idea to garbage collect like this and a

6条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-20 17:40

    Yes, most times it is a very bad idea to call System.gc(). There are exceptions but they are few and it is mostly better to spend the time making sure you are not doing things that hurt performance in a GC environment and to study and make sure you understand how a gc works than to try to handle it yourself by explicitly calling System.gc().

提交回复
热议问题