![]() |
The Java Developers Almanac 1.4Order this book from Amazon. |
e673. Getting Amount of Free Accelerated Image MemoryImages in accelerated memory are much faster to draw on the screen. However, accelerated memory is typically limited and it is usually necessary for an application to manage the images residing in this space. This example demonstrates how to determine the amount free accelerated available. Note: There appears to be a problem with
See also e601 Enabling Full-Screen Mode and e674 Creating and Drawing an Accelerated Image. GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); try { GraphicsDevice[] gs = ge.getScreenDevices(); // Get current amount of available memory in bytes for each screen for (int i=0; i<gs.length; i++) { // Workaround; see description VolatileImage im = gs[i].getDefaultConfiguration().createCompatibleVolatileImage(1, 1); // Retrieve available free accelerated image memory int bytes = gs[i].getAvailableAcceleratedMemory(); if (bytes < 0) { // Amount of memory is unlimited } // Release the temporary volatile image im.flush(); } } catch (HeadlessException e) { // Is thrown if there are no screen devices }
© 2002 Addison-Wesley. |