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

  • SEARCH
  • Home
  • 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 6471733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:15:31+00:00 2026-05-25T06:15:31+00:00

I connect to a SAP server via SAP Logon Control TLB (which eats about

  • 0

I connect to a SAP server via SAP Logon Control TLB (which eats about 25MB of mem at first start!!) and then query some data. Each call requires ~200 kB. Because I don’t want to reconnect every time, I store the connection and pass it to the SAP Function object every time I need it (it seems the object is copied, because this proc also costs about 6MB).

After I’m done querying, I free the object but the memory usage is not going down. Why?

Therefore, if I let the program run for about 4 hours, my memory is full and the PC crashes.

The code (simplified):

connection.pas (creates the connection):

SAPLogonCtrl : TSAPLogonControl;

constructor TCon.Create(usr, pswd, sys, appserv, sysnum, clnt);
begin
    inherited Create;
    SAPLogonCtrl := TSAPLogonControl.Create(nil);
    with SAPLogonCtrl do begin
        User := usr;
        Password := pswd;
        ...
        Client := clnt;
    end;
    FConnection := SAPLogonCtrl.NewConnection;
    FConnection.Logon(0, true);   //<------------- this needs ~25MB
end;

main.pas:

...
procedure TMain.Query;
var
    theQuery : TSomeQuery;
begin
    theQuery := TSomeQuery.Create;
    theQuery.Data1 := 'something gets here';
    theQuery.Data2 := 'here too';
    theQuery.Call;    // <------------------------ this needs about ~100kB
    ...
    theQuery.Free;    // <------------------------ nothing happens here, no mem freed!
end;
...

someQuery.pas (creates the object and calls the query):

var
    mySAPFunction: TSapFunctions;
    mySAPQuery: Variant;

...
procedure Call;
begin
    mySAPFunction := TSAPFunctions.Create;
    mySAPFunction.Connection := FConnection;   // <---- connection is passed (copied? costs about 5MB) from connection.pas
    mySAPFunction.RemoveAll; // removes prevous added interfaces
    mySAPQuery := mySAPFunction.Add('interface here');
    mySAPQuery.Call;
    ...
    // return the result
end;

I hope this is understandable and that someone can help me because with this memory leak my program is practically unusable 🙁

Thanks in advance,
Eike.

  • 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-25T06:15:31+00:00Added an answer on May 25, 2026 at 6:15 am

    You can force to release a variant interface instance by setting it to nil:

    procedure Call;
    begin
        mySAPFunction := TSAPFunctions.Create;
        mySAPFunction.Connection := FConnection;   // <---- connection is passed (copied? costs about 5MB) from connection.pas
        mySAPFunction.RemoveAll; // removes prevous added interfaces
        mySAPQuery := mySAPFunction.Add('interface here');
        mySAPQuery.Call;
        mySAPQuery := null; // will release the memory
    end;
    

    In fact, I think mySAPQuery should be made local to your Call procedure: in this case, the mySapQuery := null statement will be made by the compiler.

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

Sidebar

Related Questions

I connect to my remote server via ssh. Then I start my node.js app
I am trying to connect to a Microsoft SQL 2005 server which is not
I connect to the linux server via putty SSH. I tried to run it
I connect to an SQL Server 2005 DB from SAS 9.2 via SAS/Access ODBC
I need to connect to SAP and do a simple update but it will
To connect my server with the APN server I use the following code. //
How can I connect to a remote SQL server using Mac OS X? I
I connect to mysql from my Linux shell. Every now and then I run
I connect from classic ASP page to SQL SERVER 2008 R2 with following connection
I am trying to connect to twitter via TwitterVB and the following code does

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.