Memory leak
-
Hello, I apologise, if this question has been asked before. I couldn't check it because the search doesn't work. There's a memory leak in my program. The part of the memory that leaks is allocated (at least) during call ProcessShellCommand(cmdInfo) and it is allocated by function CString::AllocBuffer(by line
new BYTE[sizeof(CStringData) + (nLen+1)*sizeof(TCHAR)];
). Is there anything I can do about this memory leak?:confused: I mean because I don't directly call AllocBuffer myself, can I do anything about it? BTW the start point of my program is main and I call InitInstance() and Run() from there, if it has something to do with this. -Janetta -
Hello, I apologise, if this question has been asked before. I couldn't check it because the search doesn't work. There's a memory leak in my program. The part of the memory that leaks is allocated (at least) during call ProcessShellCommand(cmdInfo) and it is allocated by function CString::AllocBuffer(by line
new BYTE[sizeof(CStringData) + (nLen+1)*sizeof(TCHAR)];
). Is there anything I can do about this memory leak?:confused: I mean because I don't directly call AllocBuffer myself, can I do anything about it? BTW the start point of my program is main and I call InitInstance() and Run() from there, if it has something to do with this. -JanettaWhy did you use your own 'main'? Tomasz Sowinski -- http://www.shooltz.com
Never argue with an idiot, he'll bring you to his level and beat you with experience.
-
Why did you use your own 'main'? Tomasz Sowinski -- http://www.shooltz.com
Never argue with an idiot, he'll bring you to his level and beat you with experience.
-
Tomasz Sowinski wrote: Why did you use your own 'main'? It has to work as a console application in windows and unix besides gui. -Janetta
But you've copied the AfxWinMain into your main, including the calls to AfxWinTerm? Tomasz Sowinski -- http://www.shooltz.com
Never argue with an idiot, he'll bring you to his level and beat you with experience.
-
But you've copied the AfxWinMain into your main, including the calls to AfxWinTerm? Tomasz Sowinski -- http://www.shooltz.com
Never argue with an idiot, he'll bring you to his level and beat you with experience.
Tomasz Sowinski wrote: But you've copied the AfxWinMain into your main, including the calls to AfxWinTerm? No. I call AfxWinInit, InitApplication, InitInstance and Run myself. In AfxWinMain InitInstance and Run are called to a CWinThread, but I call those of the application. Could this be the problem? I tried adding AfxWinTerm after Run, but it didn't help. -Janetta
-
Tomasz Sowinski wrote: But you've copied the AfxWinMain into your main, including the calls to AfxWinTerm? No. I call AfxWinInit, InitApplication, InitInstance and Run myself. In AfxWinMain InitInstance and Run are called to a CWinThread, but I call those of the application. Could this be the problem? I tried adding AfxWinTerm after Run, but it didn't help. -Janetta
Janetta wrote: call those of the application. Could this be the problem? I don't think so, but you may try to copy AfxWinMain into your main. Tomasz Sowinski -- http://www.shooltz.com
Never argue with an idiot, he'll bring you to his level and beat you with experience.
-
Janetta wrote: call those of the application. Could this be the problem? I don't think so, but you may try to copy AfxWinMain into your main. Tomasz Sowinski -- http://www.shooltz.com
Never argue with an idiot, he'll bring you to his level and beat you with experience.
-
Hello, I apologise, if this question has been asked before. I couldn't check it because the search doesn't work. There's a memory leak in my program. The part of the memory that leaks is allocated (at least) during call ProcessShellCommand(cmdInfo) and it is allocated by function CString::AllocBuffer(by line
new BYTE[sizeof(CStringData) + (nLen+1)*sizeof(TCHAR)];
). Is there anything I can do about this memory leak?:confused: I mean because I don't directly call AllocBuffer myself, can I do anything about it? BTW the start point of my program is main and I call InitInstance() and Run() from there, if it has something to do with this. -JanettaThe CString data should delete itself when the ref count goes to zero. Which CString instance leaks? Do you do any CString::LockBuffer/CString::GetBuffer calls without matching CString::UnlockBuffer/CString::ReleaseBuffer? Another possibility is that it doesn't really leak, I've seen people here at CP complaining that their leak detector was wrong (was it BoundChecker? Purify? I can't remember, doesn't use one myself), especially when dealing with global objects (such as the global CWinApp instance). Cheers Steen. "To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
-
The CString data should delete itself when the ref count goes to zero. Which CString instance leaks? Do you do any CString::LockBuffer/CString::GetBuffer calls without matching CString::UnlockBuffer/CString::ReleaseBuffer? Another possibility is that it doesn't really leak, I've seen people here at CP complaining that their leak detector was wrong (was it BoundChecker? Purify? I can't remember, doesn't use one myself), especially when dealing with global objects (such as the global CWinApp instance). Cheers Steen. "To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
Steen Krogsgaard wrote: Do you do any CString::LockBuffer/CString::GetBuffer calls without matching CString::UnlockBuffer/CString::ReleaseBuffer? If I remember right, the things you mentioned should be ok. I can't get to the code right now, but I'll check when I can. Thanks! -Janetta