java run out of memory issue

前端 未结 6 2153
自闭症患者
自闭症患者 2021-01-04 13:13

I have a jar file running on an amazon-ec2-m1.large instance with linux 64bit operating system. I run out of memory after different hours, usually between 2-4, although in m

6条回答
  •  囚心锁ツ
    2021-01-04 13:48

    Without trying to decode the dump data, I'll observe that there are basically three cases for running a JVM out of memory:

    1. Having a structure (list of lists or whatnot) that is allowed to accumulate masses of unused (but still referenced) data.
    2. Leaving various "handles" open -- file handles, threads, data base operations. Especially if using an API with a native component you can potentially leave a lot of stuff outside of the reach of GC.
    3. Making a single extremely large request (or a "burst" of such requests).

    Kind of in-between here would be classes. If you run a app that dynamically creates and loads classes, you must properly use individual class loaders to make the classes collectable.

提交回复
热议问题