Game has a bunch of short pauses

Hi, so I’ve been working hard at managing my game’s memory, it’s currently using ~10,000kb and increases by about 200kb every half a second. (pretty good imo). However my game has very annoying short pauses (short as in less than a quarter of a second). I’m 99.99% sure it’s not the GC because my memory is not getting cleared and iirc a GC takes long than less than a quarter of a second.

What could possibly be causing this?

EDIT: These pauses stop happening when I have a fullscreen youtube video running on the other monitor…

Try using JMC’s flight recorder, you can clearly see gc pauses there, plus where that memory usage is coming from: http://www.javacodegeeks.com/2015/01/java-flight-recorder-jfr.html

I asked my dad and he said it’s probably because it is using the more powerful graphics card found in the monitor with the fullscreen youtube video playing on it.

Now the question is, how do I make it so that Java uses the best graphics card available?

Monitors don’t have graphics cards…

If your on a laptop or something with Nvidia optimus-like graphics card switching, then that might be plausible, but it would probably just result in evenly lower performance, not pauses.
I doubt it’s a vsync-like issue if the pauses are more than slight jitters.
How frequent are the pauses?

EDIT: also, are you using swing, or LWJGL, or…?

By monitor I meant laptop screen. And my macbook afaik has two graphics cards, one for everyday use and one for more intensive graphics use.

The pauses occur every 4-10 seconds.

I’m using awt

Big GC pauses are caused by having a huge heap and a lot of garbage objects being generated.

Like i said, im pretty sure it is not GC

These pauses are definitely caused by the GC doing a full scan to clear memory. Also, how/why are you creating 200kb of objects every frame? That sounds like way too many object allocations to me.

You can be sure by looking at the flight recorder, or another tool which shows GC events.

Maybe you could try recording these short pauses?

EDIT-
I wasn’t implying that you have GC pauses, I just described what big GC pauses are caused by. Also, I’m not sure about this, but 200kb of garbage doesn’t really mean anything. For all you know you might be allocating two 100kb arrays, or thousands of small objects which would be slower for GC to clean up than a couple of arrays.