Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7503599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T21:16:52+00:00 2026-05-29T21:16:52+00:00

For a web framework I tried anonymous methods for the first time and ran

  • 0

For a web framework I tried anonymous methods for the first time and ran into a problem with the memory management.

How can this memory leak (Delphi 2009) get fixed?

The leak message is:

13 – 20 bytes: Project27$ActRec x 1

program Project27;

type
  TTestProc = reference to procedure;

  procedure CallMe(Proc: TTestProc);
  begin
  end;

begin
  CallMe(procedure begin end);

  ReportMemoryLeaksOnShutdown := True;
end.

The same leak message “Project27$ActRec x 1” appears no matter how many anonymous methods are between begin and end, I guess that the leak is for the TTestProc type, not the individual anonymous procedures

program Project27;

type
  TTestProc = reference to procedure;

  procedure CallMe(Proc: TTestProc);
  begin
  end;

begin

  ReportMemoryLeaksOnShutdown := True;

  CallMe(procedure begin end);

  CallMe(procedure var A: Integer; begin A := 42 ; end);

end. 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T21:16:54+00:00Added an answer on May 29, 2026 at 9:16 pm

    When you declare an anonymous method inside a procedure or function, it gets cleaned up when that routine goes out of scope. (This is an oversimplification, but it’s good enough for the current discussion.) The problem is that the DPR’s main routine does not “go out of scope.” Instead, the Delphi compiler inserts a hidden call to System.Halt at the end of it, which never returns.

    So if you write it this way, you’re going to get the memory leak notification. You can fix it by putting the anonymous method creation inside a routine that exits normally, like so:

    program Project27;
    
    type
      TTestProc = reference to procedure;
    
      procedure CallMe(Proc: TTestProc);
      begin
      end;
    
      procedure Test;
      begin
        CallMe(procedure begin end);
      end;
    
    begin
      Test;
      ReportMemoryLeaksOnShutdown := True;
    end.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've pretty much tried every Python web framework that exists, and it took me
I'm working on a web framework and am trying to build XSS prevention into
I have published my web project to local iis but framework can't find the
I am using the WCF Web Api 4.0 framework and am running into the
Almost every Python web framework has a simple server that runs a wsgi application
I am writing a web-framework for Python, of which the goal is to be
In Apache Wicket web framework every component returns false from getOuputMarkupId() by default .
Is there a Java web framework that allows the user to create custom fields,
I'm developing (another) java web framework for personal use, and in addition to that
Hi I am looking for some web framework for my prject and I found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.