Is my memory enough?

2019-07-14 22:03发布

I am running a Java application and received this message:

 Exception in thread "main" java.lang.OutOfMemoryError: Cannot allocate new BytePointer(1200): totalBytes = 3G, physicalBytes = 7G
    at org.bytedeco.javacpp.BytePointer.<init>(BytePointer.java:103)
    at org.nd4j.compression.impl.NoOp.compressPointer(NoOp.java:73)
    at org.nd4j.compression.impl.AbstractCompressor.compress(AbstractCompressor.java:131)
    at org.nd4j.compression.impl.AbstractCompressor.compress(AbstractCompressor.java:103)
    at org.nd4j.storage.CompressedRamStorage.store(CompressedRamStorage.java:68)
    at org.deeplearning4j.models.embeddings.loader.WordVectorSerializer.loadStaticModel(WordVectorSerializer.java:2638)
    at com.dl.SentimentClassifier.main(SentimentClassifier.java:76)
Caused by: java.lang.OutOfMemoryError: Physical memory usage is too high: physicalBytes = 7G > maxPhysicalBytes = 7G
    at org.bytedeco.javacpp.Pointer.deallocator(Pointer.java:572)
    at org.bytedeco.javacpp.Pointer.init(Pointer.java:121)
    at org.bytedeco.javacpp.BytePointer.allocateArray(Native Method)
    at org.bytedeco.javacpp.BytePointer.<init>(BytePointer.java:95)

My Windows laptop has 16G memory and I am setting the Java heap size in Intellij as:

-Xms128m
-Xmx10G
-XX:ReservedCodeCacheSize=240m
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=50
-ea
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-XX:+HeapDumpOnOutOfMemoryError
-XX:-OmitStackTraceInFastThrow

What does the message mean? I am thinking it says the Java application needs 7G memory, and my heap setting is > 7G. If that is the case, why it sends a OutofMemory error?

3条回答
再贱就再见
2楼-- · 2019-07-14 22:22

First of thinking: Why does your app need too much memory? In the normal case, did you run your java app success? In that case, what is the configuration of java option? (Heapsize, GC, ...)
Next, retry with bigger max of heapsize. (16G???)
And another things that you need to check are:
- Current JVM: 32bit or 64bit?
- Physical available memory RAM and swap size are enough to expand?
If it is not problem of env setting, you need to read your library's document carefully.
Finally, I hope this link can help you Stackoverflow

查看更多
倾城 Initia
3楼-- · 2019-07-14 22:40

That means a possible memory leak, and this happens for me mostly because of some native library. In order to debug better, you can do something like following:

  1. Monitor memory before running process and then see how its growing along with process execution.

  2. See logs and check execution paths, whether there are large memory mapped addresses.

  3. Check number of threads whether they bloat up.

  4. Consider monitoring the threads stack size.

查看更多
霸刀☆藐视天下
4楼-- · 2019-07-14 22:45

You are mixing up IntelliJ IDEA JVM options and VM options specified for the apps you start from IntelliJ IDEA.

The snipped in your question is the .vmoptions file for IntelliJ IDEA and it's applied to the JVM that runs IntelliJ IDEA itself.

Your own apps run in a separate JVM that doesn't inherit the VM options of IntelliJ IDEA JVM.

JVM settings for the app can be adjusted in the corresponding Run/Debug configuration, VM options field.

vm options

查看更多
登录 后发表回答