Why does the (Oracle) JVM have a fixed upper limit for memory usage (-Xmx)?

后端 未结 8 724
生来不讨喜
生来不讨喜 2020-11-28 09:30

In the spirit of question Java: Why does MaxPermSize exist?, I\'d like to ask why the Oracle JVM uses a fixed upper limit for the size of its memory allocation pool.

8条回答
  •  醉梦人生
    2020-11-28 10:28

    Would it not make more sense to separate the upper bound that triggers GC and the maximum that can be allocated ? Once the memory allocated hits the upper-bound, GC can kick in and release some memory to the free pool. sort of like how I clean my desk that I share with my co-worker. I have a large desk, and my threshold of how much junk I can tolerate on the table is much less than the size of my desk. I don't need to have fill up every available inch before I garbage collect.

    I could also return some of the desk space that I using to my co-worker, who is sharing my desk....I understand jvms don't return memory back to the system after they've allocated it to themselves, but it does not have to be that way no ?

提交回复
热议问题