Preserved forum archive. This topic stores the original first post and locally mirrored RPG Maker Web attachments when available. It is posted by the BMMPlay archive account, not by the original creator.
Original Source
- Original title: MZ Disposing of bitmaps correctly
- Original author: kognitro
- Original date: March 3, 2024
- Source thread: https://forums.rpgmakerweb.com/threads/disposing-of-bitmaps-correctly.166444/
- Source forum path: Game Development Engines > RPG Maker Javascript Plugins > Learning Javascript
Summary
Hi, I just released my first plugin. However I'm not certain that I'm handling the disposal of bitmaps correctly. My plugin renders both images and text. The text rendering works fine when I dispose of the bitmap with:
Archived First Post
Hi, I just released my first plugin.
However I'm not certain that I'm handling the disposal of bitmaps correctly.
My plugin renders both images and text.
The text rendering works fine when I dispose of the bitmap with:
this.bitmap.destroy();
However for the image rendering, the command above alone causes images only to be displayed the first time.
I don't get errors, but the image never appears on the screen.
The main difference as far as I can see is that for the text render I'm creating a new bitmap:
this.bitmap = new Bitmap(Graphics.width, Graphics.height);
However for images its:
ImageManager.loadPicture(image_name).addLoadListener(
bmp => {
}
I've kind of got around this by doing the following:
this.bitmap = new Bitmap(1, 1);
SceneManager._scene.removeChild(this);
this.bitmap.destroy();
Which seems like a fudge, although from testing it does significantly reduce (or possibly remove) the memory leak that I was having when removing the destroy entirely.
It will likely be useful to have the plugin code to see why the destroy on it's own is causing problems for my images.
It's available here:
KOG_TextMage.js
For context, here is the post of what the plugin does:
Forum Post
Hopefully an expert here might have an idea, as currently I have no clue.
However I'm not certain that I'm handling the disposal of bitmaps correctly.
My plugin renders both images and text.
The text rendering works fine when I dispose of the bitmap with:
this.bitmap.destroy();
However for the image rendering, the command above alone causes images only to be displayed the first time.
I don't get errors, but the image never appears on the screen.
The main difference as far as I can see is that for the text render I'm creating a new bitmap:
this.bitmap = new Bitmap(Graphics.width, Graphics.height);
However for images its:
ImageManager.loadPicture(image_name).addLoadListener(
bmp => {
}
I've kind of got around this by doing the following:
this.bitmap = new Bitmap(1, 1);
SceneManager._scene.removeChild(this);
this.bitmap.destroy();
Which seems like a fudge, although from testing it does significantly reduce (or possibly remove) the memory leak that I was having when removing the destroy entirely.
It will likely be useful to have the plugin code to see why the destroy on it's own is causing problems for my images.
It's available here:
KOG_TextMage.js
For context, here is the post of what the plugin does:
Forum Post
Hopefully an expert here might have an idea, as currently I have no clue.
Downloads / Referenced Files
Log in to download
Log in, then follow the RPG Maker Developers Group to see these download links.
Log in to downloadCreator Claims / Removal
If you are the original creator and want this listing reassigned, edited, or removed, join BMMPlay and contact the moderators with proof that matches the original RPG Maker Web profile, linked GitHub, itch.io page, or another public creator identity.
Replies (0)
No replies yet.
0
replies
1
view
Topic Summary
Loading summary...