Home > Back-end > Alas, see more and more memory leaks, helpless.
Alas, see more and more memory leaks, helpless.
Time:10-11
Before always thought that is your own program memory leaks in great quantities, cause the program while it runs after many times of test found not his problem, C.e xe inject b.d ll a.e xe inside A.e xe itself has a growing problem in the operation of the memory, The problem is not I consider Then I began to seriously study b.d ll memory leak problem Found in I create threads with memory leaks in the form I create run after generics also has a memory leak, I use a number of ways, always can't correct release, really helpless, a total of more than 20 generic list
If the list. Count<> 0 then The begin
List. The clear; end; If Assigned (list) then FreeAndNil (list);
//some can release some cannot release cannot be released ahead of the strange, cause the failure of behind the release of all, Thread on the inside also has use generic list Call a process the data inside the clear first and then to add, add after, after use, to call process, this constant cycle, There is a lot of data at the end of the thread to release, Early know use generics is risky, thought wrote some of the Delphi program can feel it, but the risk really let me a headache In the BBS post to find the answer to many don't understand why don't use up, Feeling is right, but found or wrong after the execution, some compile cannot pass, feeling really good trouble ah, Is still the old question, and the release of the generic list how to correct,,,
CodePudding user response:
Ha ha, or you, I think this problem and generic, and List the container class relations is not big, You still don't feel the object lifecycle management,
I carefully looked at you on a post, give you two advice 1, if you are not familiar with Delphi memory allocation and release, suggest change structure to the class, so that create and release are safe, 2, change the TList to TObjectList, can automatically release object to you,