Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The garbage collector is running because something (in this case, probably the DB connection stack) is trying to allocate an object when there is insufficient free memory. This is normal behavior and you cannot entirely prevent it.</p> <p>The first question is, is this <em>really</em> causing a significant slowdown? The minimal evidence you have presented is unconvincing. As comments point out, slow queries are not evidence of a GC-related problem, let alone that GC is <em>causing</em> the queries to be slow. Indeed, it could be the other way around. Poor query design could be the cause of the high level of GC activity; see point 3 below.</p> <p>The second question is, why is this causing a noticeable slowdown? There are three possibilities:</p> <ol> <li><p>Simply your heap may be too small. The JVM works best, and GC is most efficient, if you can run with a big heap. If you run with a small heap, the GC runs more often and takes proportionally more time per object reclaimed. You can increase the heap size using the JVM options "-Xmx" and "-Xms"; look them up in the manual.</p></li> <li><p>Your application may have a memory leak. Over time, this will cause more and more of your heap to be filled with useless (but not garbage collectable) objects. As the heap approaches full, the GC will run more and more frequently, taking longer and longer. Eventually, the application will die with an OutOfMemoryError. The proper way to address this is to find and fix the memory leak. There are "bandaid" solutions such as increasing the heap, and using a certain JVM option to cause the JVM to exit when more than a given percentage of time is spent garbage collecting.</p></li> <li><p>Your application may just be generating huge numbers of objects as it fetches query results from the database. If this is the case, increasing the heap size will help a bit. However, you really need to look in detail at the DB queries you are performing to see if there's some way to reduce the amount of data that is retrieved from the database. Can you reduce it by doing more work on the DB side?</p></li> </ol> <p>Finally, once you have addressed the three possibilities above, you may be able to improve things further by enabling the parallel GC. This will only help if you are running on a multi-core machine.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload