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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:51:30+00:00 2026-05-26T20:51:30+00:00

I have a Delphi program and I’m looking how this program could print its

  • 0

I have a Delphi program and I’m looking how this program could print its own “virtual size” in a log file, so that I can see when it used too much memory. How can I determine the “virtual size” using Delphi code?

By “virtual size” I mean the value as displayed by Process Explorer. This value can’t be displayed by the normal task manager. It is not directly the memory usage of the program but the address space usage. On Win32 a program can not use more than 2 GB of address space.

PS: I’m using Delphi 6 but code/information for other versions should be ok too.

  • 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-26T20:51:30+00:00Added an answer on May 26, 2026 at 8:51 pm

    Thanks to this post which gives hints about how to get a virtual size using C/C++, I was able to write the following Delphi function:

    Type
      TMemoryStatusEx = packed record
        dwLength: DWORD;
        dwMemoryLoad: DWORD;
        ullTotalPhys: Int64;
        ullAvailPhys: Int64;
        ullTotalPageFile: Int64;
        ullAvailPageFile: Int64;
        ullTotalVirtual: Int64;
        ullAvailVirtual: Int64;
        ullAvailExtendedVirtual: Int64;
      end;
      TGlobalMemoryStatusEx = function(var MSE: TMemoryStatusEx): LongBool; stdcall;
    
    function VirtualSizeUsage: Int64;
    var MSE: TMemoryStatusEx;
        fnGlobalMemoryStatusEx: TGlobalMemoryStatusEx;
    begin
      Result := 0;
      @fnGlobalMemoryStatusEx := GetProcAddress(GetModuleHandle(kernel32), 'GlobalMemoryStatusEx');
      if Assigned(@fnGlobalMemoryStatusEx) then
      begin
        MSE.dwLength := SizeOf(MSE);
        if fnGlobalMemoryStatusEx(MSE) then
          Result := MSE.ullTotalVirtual-MSE.ullAvailVirtual;
      end;
    end;
    

    It seems to works great for me (Delphi 6, Win XP). There might be an easier solution using GlobalMemoryStatus instead of GlobalMemoryStatusEx but it wouldn’t work correctly on systems with more than 2 GB memory.

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

Sidebar

Related Questions

I have a Delphi 2010 ADO program that has a DBGrid. Its dataset selects
I have a program written in Delphi XE that plays a WAV file using
I have a Delphi program that creates HTML files. Later when a button is
I have a simple Delphi program that I'm working on, in which I am
I have a Delphi 2009 program that handles a lot of data and needs
I have a Delphi (5) application that uses a log-in screen (standard user name/password)
I have a program written in the Delphi Programming Language that I have to
I have a .NET application that is launched via a Delphi program using ShellExecute.
I have a Delphi 6 program that receives audio from an external program via
I have associated a file extension with my Delphi 2009 program. I have been

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.