Memory leakage superobject

Source: Internet
Author: User

In the past few days, the Code has been transplanted to the plug-in framework, because it was a single exe. I am not very concerned about memory leakage. It is different under the DLL, so add fastmm4 for monitoring debugging. It is found that there is a memory leakage during SQL parsing by scripparser.

 

There is a code segment.

 

var  lvItem            : TSuperObjectIter;begin  if ObjectFindFirst(vParam, lvItem) then  try    repeat      FScript := FastReplace(FScript, lvItem.key, FParamSetValue.S[LowerCase(lvItem.key)]);    until not ObjectFindNext(lvItem);  finally    ObjectFindClose(lvItem);  end;
 
Memory leakage exists. The problem was discovered only when I checked objectfindfirst.

Function objectfindfirst (const OBJ: isuperobject; var F: tsuperobjectiter): Boolean;
VaR
I: tsuperavlentry;
Begin
If objectistype (OBJ, stobject) then
Begin
F. ite: = tsuperavliterator. Create (obj. asobject );
F. Ite. first;
I: = f. Ite. getiter;
If I <> nil then
Begin
F. Key: = I. Name;
F. VAL: = I. value;
Result: = true;
End else
Result: = false;

// It is also possible that false is returned.

// F. ite: = tsuperavliterator. Create (obj. asobject );
End else
Result: = false;
End;

 

/// Finally modify the code without memory leakage

var  lvItem            : TSuperObjectIter;begin
  try     if ObjectFindFirst(vParam, lvItem) then    repeat      ……
    until not ObjectFindNext(lvItem);  finally
    if lvItem.Ite <> nil then ObjectFindClose(lvItem);  end;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.