- April 9, 2013 at 6:59 am #31226
I’m using PVRTexLib with a C# wrapper. To initialize my texture from memory, use this constructor “CPVRTexture(const CPVRTextureHeader& sHeader, const void* pData=NULL);”, giving NULL to the second parameter. Then i manually copy the texture data bytes at the right place using the getDataPtr method from the PVRTexture class. Then when i try using the Transcode method, the compression works and i can save my texture into a file, but it seems that can’t entirely free the memory even when calling the PVRTexture destructor. It looks like it didn’t free the “old uncompressed” data so i end up with a memory leak. This problem only happens when i try compressing my textures with the ETC2_RGBA format.
PaulApril 9, 2013 at 2:06 pm #37060
Are you using the DLL version of the library or the static version? The most common problem with the dynamic library is not defining “_WINDLL_IMPORT” in your preprocessor directives, which will solve the problem if that is the case. Alternatively it can be defined at the top of “PVRTextureDefines.h”.
You may also get this error if you’re not using the same version of Visual Studio – we use an up to date version of VS2010. VS2012 with the VS2010 toolchain also works.
TobiasApril 10, 2013 at 3:17 am #37061
I updated my version of visual studio 2010, i started a c++ project instead, i added the pre processing directive, but it doesn’t seems to do the trick. I still got the memory leak. Do you have other ideas?
Here is what i do to test:
CPVRTexture * texture;
for(int i = 0 ; i < 50 ; ++i)
texture = new CPVRTexture("C:/dev/data/stones.pvr");
Transcode(*texture, pvrtexture::PixelType('r','g','b','a',8,8,8,8), texture->getChannelType(), texture->getColourSpace());
Transcode(*texture, ePVRTPF_ETC2_RGBA, texture->getChannelType(), texture->getColourSpace());
}April 10, 2013 at 10:06 am #37062
This code definitely works for me without a memory leak. Can I ask what version of PVRTexLib you’re using? The latest version is 4.5 – If you’re not on this version I’d suggest updating to make sure that you’ve got all the latest fixes.
On older versions it was slightly broken and you actually had to set _WINDLL_IMPORT to equal 1, so I’m just wondering if you’re running one of those versions.