Hi all,

getAvailableAcceleratedMemory
<https://docs.oracle.com/en/java/javase/19/docs/api/java.desktop/java/awt/GraphicsDevice.html#getAvailableAcceleratedMemory()>'s
implementation (and lack thereof) is in conflict with the documentation,
making it quite problematic.

Windows is the only OS that has it implemented; macOS and Linux will return
-1. The bigger problem is that the return type is an int, which can't
represent the amount of bytes in modern systems. Representing the amount of
bytes in video memory with a signed 32-bit integer has a cap of 2047MB. My
GPU has 6x that amount.

Windows' impl uses this D3D function
<https://learn.microsoft.com/en-us/windows/win32/api/d3d9helper/nf-d3d9helper-idirect3ddevice9-getavailabletexturemem>,
returning
an *unsigned* 32-bit integer, closest to the actual amount of bytes it can
represent--ending up with a negative number when it's signed. The
documentation says "A negative return value indicates that the amount of
accelerated memory on this GraphicsDevice is indeterminate." Technically
true, but less than helpful.

The documentation for the method is... uh... probably outdated anyway as to
what the method can be used for. So our remedial options are to change the
documentation; implement macOS and Linux; deprecate it; change the return
type; or any combination. (My thoughts are for deprecating.)

What should we do?

-SWinxy

Reply via email to