fullPathFromRelativePath memory leak?

fullPathFromRelativePath memory leak?
0.0 0


If used this code:(cocos2d-2.0-rc2-x-2.0.1)

for(int i = 0; i < 1000; ++i )
std::string fullPath = CCFileUtils::sharedFileUtils( ) > fullPathFromRelativePath;@
And if used code:
std::string fullPath = CCFileUtils::sharedFileUtils
> fullPathFromRelativePath( str);

(CFString “Live Bytes” ~40 Kb)

We have memory leak? (CFString used ~1 Mb on 1000 iteration) why?

Sorry my english is bad.


Could you please test it on the latest version cocos2d-2.0-x-2.0.2?
Thank you.


Has updated to cocos2d-2.0-x-2.0.2
Unfortunately the new version does not correct this bug.
But I saw that (2.0.2) is a new memory leak in CGColorTransformCache (~10kb per second, this was not in the previous version).

tested on a standard app “Hello World”


Oh, really?
I will checkout it.
Thank you for your feedback.


I have seriously checked out the codes of CCFileUtils::fullPathFromRelativePath(), but can not memory leak.
Is it because the memory is not recycled in time?


Thank you for your time,
maybe it does not leak memory ( maybe it zombie memory),
I thought that fullPathFromRelativePath temporary, can cause a lot of times without a thought about memory.
But how to clear memory that fullPathFromRelativePath captured?
It is possible in the execution?


I added the codes you pasted and run with profile(Leaks).
And it didn’t say there is a memory leak.


Then why when I execute this code
const char *str = "CloseNormal.png"; for(int i = 0; i < 100000; ++i ) { CCFileUtils::sharedFileUtils( ) -> fullPathFromRelativePath( str); }
i have:

But when I execute this code
const char *str = "CloseNormal.png"; for(int i = 0; i < 10; ++i ) { CCFileUtils::sharedFileUtils( ) -> fullPathFromRelativePath( str); }
i have:

CFString used only fullPathFromRelativePath;

Please help me somebody, i don’t know how to solve this problem:(


I got the same problem! and I add an method to solve this

std::string CCFileUtils::getResource(const char pszRelativePath)
std::string strRet = “”;
@autoreleasepool {
relPath = [NSString stringWithUTF8String:pszRelativePath];
NSString *fullpath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:relPath];
strRet = [fullpath UTF8String];

if (strRet.size() == 0) {
throw ;
return strRet;

hope this may help.