java - Why this happens in garbage collection injava -


as know when run garbage collection using system.gc() method collect unused , undestroyed objects heap , clean it. when run system.gc(); memory of jvm should increased. in below code when run it, result confusing me.

runtime rs = runtime.getruntime(); system.out.println("free memory in jvm before garbage collection = " +                     rs.freememory()); rs.gc(); system.out.println("free memory in jvm after garbage collection = " +                    rs.freememory()); 

the output

free memory in jvm before garbage collection = 12184624 free memory in jvm after garbage collection = 12184360     

see before value greater after value.

please correct me if in wrong concept or explain me why happen.

thank you.

calling garbage collection in java merely suggestion jvm. way garbage collected technically 100% out of control. calling system.gc() politely suggests trash should taken out, java within rights ignore disobedient child.

although ask, won't , can't rely on it.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -