0
這會在運行幾秒鐘後產生OutOfMemory異常。有任何想法嗎?處理圖像時的OutOfMemory
PGraphics img;
void setup() {
size(500, 500);
img = createGraphics(width, height, JAVA2D);
// this is here just for the testcase because else I get a
// NullPointerException too (probably a harmless Processing bug)
img.beginDraw(); img.endDraw();
}
void draw() {
PGraphics tmpImg = createGraphics(img.width, img.height, JAVA2D);
tmpImg.beginDraw();
tmpImg.image(img, 0, 0);
tmpImg.endDraw();
tmpImg.dispose();
}
它可能有可能是你的內存泄漏的地方。這可以通過一個好的分析器軟件或者一個非常好的調試器來找到。 – evotopid
你是否真的應該在每次輸入draw時創建一個新的PGraphics? – Mat