When to Garbage Collect

前端 未结 8 1242
逝去的感伤
逝去的感伤 2020-12-11 04:24

I have a piece of code that load a very big image in memory. So it seemed like a reasonable thing to call

System.gc();

before loading the

8条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-11 04:47

    You already got plenty of good advice, which I will try not to reiterate.

    If you actually get problems with the GC, like full stops of your application for a second, do the following: 1. check that there aren't any calls to System.gc(); 2. check out the various options for configuring the gc. There are tons of those around, and they are much more helpful, then forcing gc.

提交回复
热议问题