double memory when loading a texture? WHY?
-
- Posts: 5
- Joined: Wed Oct 24, 2007 5:40 pm
double memory when loading a texture? WHY?
guys, i am loading a 4mb , 1024x1024 , uncompressed TGA texture and when i use the IrrVideoDriver.GetTexture to load it up, it consumes 8.2MB of system memory!
I REALLY cant see a reason for that, why would it consumes double the memory of the normal texture?
i already set the CreateMipMaps to false , and it reduced a little bit but not even close to the real one...
i tried to do the same thing using another engine , TRUEVISION3D , and on it, it consumed 5.5 mb.
could someone enlight me up of why is that happening or what should i do to reduce it more?
thank you
I REALLY cant see a reason for that, why would it consumes double the memory of the normal texture?
i already set the CreateMipMaps to false , and it reduced a little bit but not even close to the real one...
i tried to do the same thing using another engine , TRUEVISION3D , and on it, it consumed 5.5 mb.
could someone enlight me up of why is that happening or what should i do to reduce it more?
thank you
-
- Posts: 5
- Joined: Wed Oct 24, 2007 5:40 pm
OK, thats not the case, i made the test using a .bmp file(btw, same specifications, 4mb , 1024x1024) and it still eating up the same ammount of memory (8.2 mb)
any other ideas??? anyone?
any other ideas??? anyone?
Last edited by necropower on Wed Dec 19, 2007 1:57 pm, edited 1 time in total.
-
- Posts: 5
- Joined: Wed Oct 24, 2007 5:40 pm
Are you using the newest Irrlicht version? I know that in older versions (< 1.2) one copy was made in CImage.cpp which was not really needed in most cases. But that part seems to be rewritten, so I supposed that this is solved in a better way by now. Though I have not yet done memory tests for newer versions myself.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
maybe if your tga is saved with 16Bit color-depth or if it is saved as 16bit bitmap there isn't W*H*4byte.
if its a 16bit image it would be W*H*4*4Bit
from these not all formats can store alpha channel so it would be W*H*3*4Bit
list:
32bit with alpha: W*H*4byte
24bit (same without alpha): W*H*3byte
16bit with alpha: W*H*2byte (W*H*4*4Bit)
16Bit without alpha: W*H*3*4Bit
8Bit -> 1Byte
so it would be correct that the ammount of used memmory is higher than image file size when the image is internaly saved as 32Bit Bitmap
if its a 16bit image it would be W*H*4*4Bit
from these not all formats can store alpha channel so it would be W*H*3*4Bit
list:
32bit with alpha: W*H*4byte
24bit (same without alpha): W*H*3byte
16bit with alpha: W*H*2byte (W*H*4*4Bit)
16Bit without alpha: W*H*3*4Bit
8Bit -> 1Byte
so it would be correct that the ammount of used memmory is higher than image file size when the image is internaly saved as 32Bit Bitmap
-
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
Hmm. DIRECTX9, right? CD3D9Texture is hanging onto the CImage that's used to decode the image until the actual DirectX texture is deleted. I can't see any need for that. This isn't a candidate patch, it just demonstrates (e.g. by running the demo example app with DX9) that there's no harm to dropping the image after it's used to create the DX9 texture. The CImage (and the duped memory) then gets freed in CNullDriver::loadTextureFromFile().
Code: Select all
Index: source/Irrlicht/CD3D9Texture.cpp
===================================================================
--- source/Irrlicht/CD3D9Texture.cpp (revision 1113)
+++ source/Irrlicht/CD3D9Texture.cpp (working copy)
@@ -90,6 +90,9 @@
}
else
os::Printer::log("Could not create DIRECT3D9 Texture.", ELL_WARNING);
+
+ Image->drop();
+ Image = 0;
}
}
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
-
- Posts: 5
- Joined: Wed Oct 24, 2007 5:40 pm
-
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
Yup, I've raised a bug report and candidate fix. Thanks for reporting this.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way