Why do I get an OutOfMemoryError when inserting 50,000 objects into HashMap?

前端 未结 10 1935
猫巷女王i
猫巷女王i 2021-02-01 08:12

I am trying to insert about 50,000 objects (and therefore 50,000 keys) into a java.util.HashMap. However, I keep getting an OutOfMemo

10条回答
  •  日久生厌
    2021-02-01 08:45

    Implicit in these answers it that Java has a fixed size for memory and doesn't grow beyond the configured maximum heap size. This is unlike, say, C, where it's constrained only by the machine on which it's being run.

提交回复
热议问题