Is it a memory leak if the garbage collector is not working properly?

I developed an application for the J2ME web browser, it works fine. I am testing its memory consumption. It seems to me that it has a memory leak because the green curve representing the consumed memory of the memory monitor (a set of wireless network tools) reaches the maximum allocated memory (which is 687768 bytes) every 7 requests made by the browser (i.e. when the end user moves in a web browser from one page to another 7 pages), after which the garbage collector starts and frees the allocated memory.

My question is:

  • Is it a memory leak when the garbage collector starts automatically every 7 pages of navigation?
  • Do I need to manually run the garbage collector (System.gc ()) once for each request to prevent access to the maximum allocated memory?

I beg you, thanks

+5
source share
5 answers

To determine if this is a memory leak, you will need to monitor it more.

From your description, that is, as soon as the maximum memory is reached, the GC will start working and be able to free up memory to run your application, this is not like a leak.

Also, you should not call GC yourself, as

  • this is only an indicator
  • can potentially affect the underlying algorithm, affecting its performance.

Instead, you should focus on why your application needs so much memory in such a short period.

+3

: , 7- ?

. :

  • , ,

  • () .

, , , , . GC , THAT , , , , ; .

(System.gc()) , ?

. .

System.gc() . , System.gc() . , , , RUN LOT SLOWER... , JVM .


, JVM HotSpot System.gc():

Java 7:

./OpenJDK/ /SRC//VM//globals.hpp

  product(bool, DisableExplicitGC, false,                                   \
          "Tells whether calling System.gc() does a full GC")               \

false . ( , OS/M/C .)

+1

, , GC. , System.gc() . , . , GC.

+1

() . ( ) , , .

GC, "". , , , . , "" .

Running System.GC - -op, .

, ( Android) " " Java ( JVM). , "" Java, - , . , , . , , (.. GC), .

0

:

, .

A memory leak is when unused memory cannot be garbage collected because it still has links somewhere (although they are not used).

Garbage collection is when a piece of software (the garbage collector) automatically frees up immutable memory.

You cannot call the garbage collector manually, as this will affect its performance.

0
source

All Articles