Maximum amount of memory per Java process on Windows?

后端 未结 5 1599
粉色の甜心
粉色の甜心 2020-11-27 14:06

What is the maximum heap size that you can allocate on 32-bit Windows for a Java process using -Xmx?

I\'m asking because I want to use the ETOPO1 data i

5条回答
  •  盖世英雄少女心
    2020-11-27 14:24

    As noted in the question mentioned in the comment, there is a practical limit, circa 1200 MB.

    However the situation you're describing has more depth to it than sheer memory size.

    When you read a 910 MB binary data and build a network objects off of it (as opposed to just maintaining the data as an array of bytes), you end up consuming much more memory than 910 MB. A reasonable estimate would be that the in-memory representation will consume twice as much memory - that's because (1) each object contains an additional pointer (to the class of the object); and (2) there's a lot bookkeeping data. For instance if you use a HashMap to manage your objects then in addition to each object you also allocate a Map.Entry object which can easily consume 16 or 20 bytes (implementation dependent).

    On the other hand, there's still hope: do you really need to maintain all 910 MB in memory? Can't you just build something that reads the data in a lazy manner? Combined with WeakReferences I think you can pull this off.

提交回复
热议问题