关于System.gc()

javadoc说:

Calling the gc method
suggests that the Java Virtual Machine expend effort toward recycling unused objects in order to make the memory they currently occupy available for quick reuse. When control returns from the method call, the Java Virtual Machine has made a best effort to reclaim space from all discarded objects.

  注意,只是“建议”JVM干这样一种事,不是直接命令

  另外,在HotSpot中,System.gc()将导致JVM发起一次Full GC,不是Minor GC

  另据本人网上搜集,代码里基本不用这个东西。

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.