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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:47:54+00:00 2026-05-11T01:47:54+00:00

I need to know how much physical memory a windows machine has, using Perl.

  • 0

I need to know how much physical memory a windows machine has, using Perl.

I’ve tried using Win32::SystemInfo. However this module states the following caveat:

On Intel x86 computers with more than 2 GB and less than 4 GB of memory, the MemoryStatus function will always return 2 GB for TotalPhys. Similarly, if the total available memory is between 2 and 4 GB, AvailPhys will be rounded down to 2 GB.

So on a machine which has 2-4 GB of physical memory, I get a false answer.

Is there a way to get the correct amount of physical memory? Perhaps another module? Or directly using Win32::API?

Edit: From the comments people gave here, it looks like the limitation is in the Win32 API , and not specific to Win32::SystemInfo. However, the OS does know exactly how much physical ram is available, so there must be a way to extract that information. If not in Perl then maybe in another language?

  • 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. 2026-05-11T01:47:55+00:00Added an answer on May 11, 2026 at 1:47 am

    As stated in the comments, this is an issue of GlobalMemoryStatus, as it can return answers up to 2GB. And GlobalMemoryStatusEX which solves this issue of the 2GB limit, but only works on 64 bit systems (as far as I can tell).

    In the end I’m using the following Perl code, which uses Win32::OLE and WMI class Win32_PhysicalMemory, which returns the correct amount of physical memory even on 32bit systems:

    use strict; use warnings; use English; use Win32::OLE qw( EVENTS HRESULT in ); use Readonly;  sub get_physical_memory {     my $machine                         = shift || '.'; # Default to local machine     my Readonly $WMI_MEMORY_CLASS_NAME  = 'Win32_PhysicalMemory';     my Readonly $MEGABYTE               = 1024*1024;      my $WMI =          Win32::OLE->GetObject( 'winmgmts:{impersonationLevel=impersonate,(security)}//$machine/' ) || die 'Could not get Win32 object: $OS_ERROR';     my $total_capacity                  = 0;      foreach my $object ( in( $WMI->InstancesOf( $WMI_MEMORY_CLASS_NAME ) ) ) {         $total_capacity += $object->{Capacity};     }      my $total_capacity_in_mb            = $total_capacity / $MEGABYTE;     print 'Total Memory : $total_capacity_in_mb \n';     return $total_capacity_in_mb; } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 80k
  • Answers 80k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Your RHS is only using Int32 values, so the whole… May 11, 2026 at 4:23 pm
  • Editorial Team
    Editorial Team added an answer There is no special licencing (like Academic) to buy Developer… May 11, 2026 at 4:23 pm
  • Editorial Team
    Editorial Team added an answer If the string is short, then just looping and testing… May 11, 2026 at 4:23 pm

Related Questions

I looked online for some references but didn't have too much luck. Hopefully it's
I need to know how much space occupies all the databases inside an SQL
Is there any way how to tell component in WPF to take 100% of
I need to know the maximum length of a textbox in ssrs. How much

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.