Java & # 8594; System.gc (); Does this call open a new topic or not?

For example, I have such a code

... get some memory and lose all pointers to that memory to System.gc (); can collect it.

call System.gc ();

perform some other tasks;


Here, "perform some other tasks" is performed; and "System.gc ();" works in parallel or performs "other tasks"; waiting for "System.gc ();" for execution

thank

+3
source share
9 answers

JVM. spec ( , JVM), , , , .

JVM, , , . , . "-" ( ).

, @Chris Dail, System.gc(). Calling System.gc() . , , . , "-" , " " , . ( , , JVM , ).

, , OutOfMemoryError. JVM OutOfMemoryError, , . Calling System.gc . OutOfMemoryError, , , , , , .

+5

, System.gc(). , C/++ Java, , , . , , , . System.gc() .

System.gc(), "" . , . , . , . , , , .

+7

, .

, , JVM , .

, -verbosegc.

- , JVM - , System.gc() - , , , .

+4

JVM. , , , . Sun , .

+1

Eric Eijkelenboom , , . , ...

( Amarghosh), , -, ? . , , .

+1

" " System.gc() .

0

. System.gc() , , . JVM .

0

javadoc http://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html#gc(): " , Java , ".

, , " "; "System.gc();" !

parallelism - Java-. , / . - ...

Bye, Alban.

0

Java , System.gc(), , GC . , , JVM , Sun JVM (-XX:-DisableExplicitGC). System.gc() .

. GC; Sun JVM , .

As pointed out by others, a pure call effect System.gc()obviously in most cases leads to a decrease in performance. If you feel that you should call this method, chances are you are doing something wrong.

0
source

Source: https://habr.com/ru/post/1741767/


All Articles