PVRTexLib Memory leak when using the Transcode method with ETC2_RGBA compression format

Hi,

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.

Regards,

Paul

Hi Polco,



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.



Thanks,

Tobias

Hi

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?

Thanks !



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());



delete texture;

}

Hi Polco,



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.



Regards,

Tobias

Hi,



I have the last version (4.5), so i really don’t know where the problem comes from -_- . I thank you anyway for your time.



Regards,

Polco