LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: OverBlob on November 22, 2012, 12:34:49

Title: Graphic Memory and CPU usage
Post by: OverBlob on November 22, 2012, 12:34:49
Hi !
Do you know if there is a way to obtain the RAM, the graphic memory and the CPU usage in LWJGL?

I thought it would be better to get it as soon as possible in order to see what uses the most resources of my computer so I can make early optimizations in my code. :)
Title: Re: Graphic Memory and CPU usage
Post by: CodeBunny on November 24, 2012, 14:40:44
I don't know about getting GPU stats, but I can help you with CPU-side stuff.

Also, remember that your java application is being run within the JVM. As such, you can ask the JVM for certain statistics about your program.

To detect the amount of memory being used/the maximum amount of memory possible, I believe Runtime has some methods that let you detect that.

As for "CPU usage", I'm not sure how you would detect that and I really don't think it's all that useful of a statistic. You'd probably be more interested in "completion time" statistics - how long it takes your game loop to complete before sleeping. Alternatively, you may be interested in the percentage of your game loop that is not spent sleeping. For both of these figures, you'd probably use System.nanotime() in order to get the initial durations, and then do some conversions/comparisons.
Title: Re: Graphic Memory and CPU usage
Post by: princec on November 24, 2012, 22:56:23
I think JMX beans have some tools for this.

Cas :)
Title: Re: Graphic Memory and CPU usage
Post by: OverBlob on November 25, 2012, 12:21:41
Okay thank you guys, I'll dig in thoose ways ! :)