I’ve actually been using your interface to track direct memory for a while and it has always worked consistently to track the current Directory memory being used with the
I just checked the method to get the max direct memory value to see if it reports what I set in the JVM argument, and it appears
getDirectMemoryTotalCapacity() always returns the same exact value as the method for current memory usage
As for tracking my current memory usage, the interface has been very helpful - I notice that whenever I reach a current DM usage value near the max direct memory parameter set by the JVM arguments, then the game’s framerate will drop for a while until the app inevitably crashes from an OutOfMemory exception (which will be triggered by any random piece code that loads a new asset that tips the memory usage past the max).
I’ve also noticed that all of my devices have a limit where they crash on startup if the JVM argument for max direct memory usage is too high (as well as max heap usage), with an “Unable to allocate memory for JVM” error, but usually its much lower than the amount of total ram for the device. And I think I remember reading something about direct memory and/or heap memory inherently increasing as you increase the other - something like more direct memory usage needed for overhead as you increase the heap memory argument. I think I noticed this first hand at one point when I needed to increase my heap usage JVM param by 100mb to support a new feature that caused OOM crashes with many NPCS, and it solved that heap OOM error, but caused a new direct memory OOM error on the loading screen, which was fixed by increasing the direct memory JVM param slightly.
I guess the quickest solution then would be for me to run the jar from a batch file with the memory params included there.