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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:17:58+00:00 2026-06-06T11:17:58+00:00

Is there any way to get how much memory a service application is using

  • 0

Is there any way to get how much memory a service application is using only knowing its service name?

  • 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-06-06T11:18:00+00:00Added an answer on June 6, 2026 at 11:18 am

    First you must retrieve the Pid of the associated process to the service using the QueryServiceStatusEx function or the Win32_Service WMI Class and then you can use the GetProcessMemoryInfo function to Collect the Memory Usage Information of the process.

    Check this sample App

    {$APPTYPE CONSOLE}
    
    uses
      ActiveX,
      ComObj,
      Variants,
      Windows,
      psApi,
      SysUtils;
    
    function  GetPidFromService(const ServiceName : string) : DWORD;
    const
      WbemUser            ='';
      WbemPassword        ='';
      WbemComputer        ='localhost';
      wbemFlagForwardOnly = $00000020;
    var
      FSWbemLocator : OLEVariant;
      FWMIService   : OLEVariant;
      FWbemObjectSet: OLEVariant;
      FWbemObject   : OLEVariant;
      oEnum         : IEnumvariant;
      iValue        : LongWord;
    begin;
      FSWbemLocator := CreateOleObject('WbemScripting.SWbemLocator');
      FWMIService   := FSWbemLocator.ConnectServer(WbemComputer, 'root\CIMV2', WbemUser, WbemPassword);
      FWbemObjectSet:= FWMIService.ExecQuery(Format('SELECT ProcessId FROM Win32_Service Where Name="%s"',[ServiceName]),'WQL',wbemFlagForwardOnly);
      oEnum         := IUnknown(FWbemObjectSet._NewEnum) as IEnumVariant;
      if oEnum.Next(1, FWbemObject, iValue) = 0 then
        Result:=FWbemObject.ProcessId;
    end;
    
    procedure MemoryInfoService(const ServiceName : string);
    var
      hProcess : THandle;
      ppsmemCounters: PPROCESS_MEMORY_COUNTERS;
      cb: DWORD;
    begin
      hProcess := OpenProcess(PROCESS_VM_READ or PROCESS_QUERY_INFORMATION, False, GetPidFromService(ServiceName));
      if hProcess <> 0 then
      try
       cb:=SizeOf(PROCESS_MEMORY_COUNTERS);
       GetMem(ppsmemCounters, cb);
       try
       if  GetProcessMemoryInfo( hProcess, ppsmemCounters, cb) then
       begin
          Writeln( Format('PageFaultCount: %d',[ ppsmemCounters.PageFaultCount]));
          Writeln( Format('PeakWorkingSetSize: %d',[ ppsmemCounters.PeakWorkingSetSize]));
          Writeln( Format('WorkingSetSize: %d',[ ppsmemCounters.WorkingSetSize]));
          Writeln( Format('QuotaPeakPagedPoolUsage: %d',[ ppsmemCounters.QuotaPeakPagedPoolUsage]));
          Writeln( Format('QuotaPagedPoolUsage: %d',[ ppsmemCounters.QuotaPagedPoolUsage]));
          Writeln( Format('QuotaPeakNonPagedPoolUsage: %d',[ ppsmemCounters.QuotaPeakNonPagedPoolUsage]));
          Writeln( Format('PagefileUsage: %d',[ ppsmemCounters.PagefileUsage]));
          Writeln( Format('PeakPagefileUsage: %d',[ ppsmemCounters.PeakPagefileUsage]));
       end;
       finally
         FreeMem(ppsmemCounters);
       end;
      finally
        CloseHandle(hProcess);
      end;
    end;
    
    begin
     try
        CoInitialize(nil);
        try
          MemoryInfoService('FirebirdGuardianDefaultInstance');
        finally
          CoUninitialize;
        end;
     except
        on E:EOleException do
            Writeln(Format('EOleException %s %x', [E.Message,E.ErrorCode]));
        on E:Exception do
            Writeln(E.Classname, ':', E.Message);
     end;
     Writeln('Press Enter to exit');
     Readln;
    end.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way to get the effect of running python -u from within
Is there any way to get the location of a cell phone (i.e. latitude/longitude)
Is there any way I get get the size of an NSWindow (in pixels)
Is there any way to get the local end point of a connected Silverlight
Is there any way to get a map or other data structure of the
Is there any way to get just a part from MySql cell and ignore
Is there any way to get the date January 1, 1970 Greenwich Mean Time
Is there any way to get the work item query results preview pane to
Is there any way to get the content of a UIWebView and convert it
Is there any way to get the # of months and years since a

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.