|
메모리 누수에 관해서 질문했엇는데 아무도 답글을 안달아주시네요 ㅠㅠ
윈도우즈 작업관리자로 메모리를 보니
갈수록 점점 커져서, 몇일 동안 헤메다가 겨우 원인을 알았네요
TList 를 사용해서 파일 스트림을 읽어
메모리에 모든 파일을 저장해두고 사용했엇는데
TStream *strm1 = new TStream;
strm1->LoadFromFile("filename1");
TList->Add(strm1);
TStream *strm2 = new TStream;
strm2->LoadFromFile("filename2");
TList->Add(strm2);
....
파일들을 다시 새로 읽어들일때
TList에 연결된 스트림을 다지우고 다시읽어들이려고 TList::Clear을보니
TList::Clear Description에
Clear also 'frees the memory used to store the Items array' and sets the Capacity to 0.
이라고 써있어서
TList->Clear();
...
로 초기화하고 다시 파일을 읽어들였는데
알고보니 메모리 해제를 제대로 못하더군요;;
실제로 Clear()은
for(int i=0; i<DBPhotoList->Count; i++)
delete DBPhotoList->Items[i];
이런식으로 아이템들을 지우는듯합니다.
그래서
for(int i=0; i<DBPhotoList->Count; i++)
delete []DBPhotoList->Items[i];
TList->Clear();
이렇게 직접 아이템들을 지웠더니 깔끔하게 메모리가 해제되더군요 ㅎㅎ;
이거 알아내는데 1주일걸린 ㅜㅜ.
다시한번 질문합니다.~
메모리누수 빌더에서 어떻게 쉽게 찾나요??
|