Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarification please regarding OnFreeNode handling for strings etc #1219

Open
gwideman opened this issue Sep 23, 2023 · 2 comments
Open

Clarification please regarding OnFreeNode handling for strings etc #1219

gwideman opened this issue Sep 23, 2023 · 2 comments
Labels
Repro Steps Missing A smple project is needed to reprodcue and analyze the issue. See our guidelines for opening issues!

Comments

@gwideman
Copy link

The OnFreeNode event Help doc mentions: "You should however finalize the data in such a case if it contains references to external memory objects (e.g. variants, strings, interfaces)."

Could we get a more explicit description or example of how to handle this? Does it mean calling Finalize on each individual dynamically-allocated field? Or is it possible to call a single function (possibly Finalize), passing the entire data record?

I am not 100% sure from the Embarcadero doc how to do this. The example page "System InitializeFinalize (Delphi) shows:

  PPerson = ^TPerson;
  TPerson = record
    FFirstName: String;
    FLastName: String;
    FAge: Integer;
  end;
[...]
  GetMem(Person, SizeOf(TPerson));
  Initialize(Person^);
[...]
Finalize(Person^);
FreeMem(Person);

For the TVirtualStringTree node data, I think we skip GetMem and Initialize, but in OnFreeNode we have to:

pNodeData := vst.GetNodeData(Node);
Finalize(pNodeData^);

... and I think the FreeMem is unnecessary and should not be called.

Is all that right?

Thanks.

@livius2
Copy link
Contributor

livius2 commented Oct 29, 2023

Simply turn on System.ReportMemoryLeaksOnShutdown:= true; in Form OnCreate and check results with and without FreeMem

@joachimmarder
Copy link
Contributor

Please understand that we do not provide technical support for Virtual TreeView here. Please try to get support from the community e.g. at Stack Overflow , Delphi Pages or Delphi Praxis . Please do not use GitHub issues for getting support. 
 
If you feel you found a bug, please respect our guidelines on the project homepage for submitting bugs. Please include your version of Virtual TreeView and Delphi, and attach a sample compiling project as ZIP to your report, or instructions how to modify one of the included sample projects to reproduce the problem. If only small changes are required, a description is sufficient how a demo projects needs to be changed in order to replicate the bug. If you already have a solution, please supply a patch file.

@joachimmarder joachimmarder added the Repro Steps Missing A smple project is needed to reprodcue and analyze the issue. See our guidelines for opening issues! label Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Repro Steps Missing A smple project is needed to reprodcue and analyze the issue. See our guidelines for opening issues!
Projects
None yet
Development

No branches or pull requests

3 participants