英文:
what will happen when eden is full but all objects in it is alive
问题
我正在学习Java内存管理,根据我已经从互联网上学到的知识。
当Eden空间满时,将触发Minor GC,Minor GC将把仍在被引用的对象复制到一个空的幸存者空间,但该空间比Eden小。当Eden装满存活对象时,收集器会做什么?据我所知,Java GC收集器是一个复制收集器,它应该将所有存活对象移开,然后清除旧的内存空间。
英文:
I am learnging Java memory management, From what I already learned from internet.
Minor GC is triggered when Eden space is full, Minor GC will copy objects still being referenced to one survivor space which is empty, but that space is smaller than Eden, What will collector do when eden is full of alive objects ? AFAIK,Java GC Collector is copying collector, it should move all live objects away then clear old memory space.
答案1
得分: 1
> 当Eden空间满时会触发小型GC。
几乎是正确的。当主要GC被触发时,也可以触发小型GC。这就像垃圾收集器说:“我需要执行一次完全GC,但首先我会执行一次小型GC”。在这种情况下(例如G1
就是这样做的),Eden空间
可能并不是满的。
当发生这种情况时(某些Eden
区域无法完全清空时),这些区域会被标记为老年区,正如这里的注释所述:
> 未能清空的区域总是会变成老年区...
英文:
> Minor GC is triggered when Eden space is full
almost correct. A minor GC can be triggered when a major GC is triggered. It's like the GC says : "I need to do a Full GC, but first I'll do a minor one". In that case (G1
does this, for example), Eden space
might not be full.
When that happens (some Eden
regions could not be completely evacuated), those regions are made old, as even commented here:
> Regions that failed evacuation are always made old...
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论