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 3315760
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:23:18+00:00 2026-05-17T22:23:18+00:00

HI I have a dynamic link library writting in Delphi 2006 that has forms.pas

  • 0

HI

I have a dynamic link library writting in Delphi 2006 that has forms.pas in its uses clause.

If I load the dll and then immediately unload it in a for loop, say 10000 times, the memory slowly climbs. However if I take Forms.pas out of the uses clause of the dll then the problem goes away.

The code is very simple

Here is my code for the dll:

library Project1;

uses
  Forms;

begin

end.

Here is my code for the calling application:

procedure TForm1.Button1Click(Sender: TObject);
var
  t_ImportHandle: LongInt;
  t_Index: Integer;
begin
  for t_Index := 0 to 10000 - 1 do
  begin
    t_ImportHandle := LoadLibrary('Project1.dll');
    FreeLibrary(t_ImportHandle);
  end;
 end;

Is anyone else able to replicate this or know what the cause is and how to fix it?

  • 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-17T22:23:19+00:00Added an answer on May 17, 2026 at 10:23 pm

    TApplication.Create uses the MakeObjectInstance function in Classes.pas. MakeObjectInstance allocates a 4KB buffer using VirtualAlloc, but doesn’t free it, so each time you load/unload the DLL it’s going to leak that much. Andreas Hausladen used to have a blog post about it, but it looks like he’s taken it down. There’s a fix posted on CodeCentral, and it’s also included as part of Andreas’s VCL Fix Pack package.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Dynamic Data Entities Web Application that uses a database with GUIDs
I have a dynamic link library written in VC++6. I wrote some code with
I have a native dynamic link library written in VC++6 and I do not
I have a dynamic query that returns around 590,000 records. It runs successfully the
I have a dynamic class that serves as a storage container for configuration settings.
Normally it happens that when ever the path of the library that has to
I'm using Delphi 2007 Pro. I have a runtime package that includes a number
How can I have a dynamic variable setting the amount of rows to return
When C# 4.0 comes out and we have the dynamic keyword as described in
We're looking at doing a MOSS 2007 site which will have a fairly dynamic

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.