Memory leak in J2ME - continued 1-double buffer

zhaozj2021-02-16  42

This article is primarily part of the "J2ME's memory leak" article. Here is mainly to say that some people who are easy to generate in the double buffer may have no double buffer. Here is a simple introduction to the double buffer is to open up a new space in memory. You can draw pictures on it, then draw together Go to the phone screen. The most advantageous benefits of using double buffering can improve the drawing speed, the disadvantage is to consume memory. Create a dual-eugenic example: Image Dimage = image.createImage (width, height); // Create a picture of the specified size Graphics DG = DIMAGE.GRAHICS (); // Get the product's graphics then you can use DG Objects to draw images Image D = image.createImage ("/ 1.png"); DG.DrawImage (d, 0, 0, graphics.top | graphics.Left); Finally draw this picture in the mobile phone screen. G.DrawImage (Dimage, 0,0, graphics.top | graphics.Left);

When you release the dual buffer space, you cannot just release the DIMAGE object, such as: DIMAGE = NULL; also releasing the DG object, otherwise, DIMAGE will not be released, so it may cause memory leakage. Because of this: DG = NULL; DIMAGE = NULL; this is just my experience. I hope to help everyone.

转载请注明原文地址:https://www.9cbs.com/read-26908.html

New Post(0)