In a 64-bit system, How much memory can a 32-bit program apply for, 4 GB or more? (1)

Source: Internet
Author: User
Preface:

CPU bit refers to the amount of data that can be processed at a time, 1 byte = 8 bits, 32-bit processors can process 4 bytes of data at a time, and so on. 32-bit operating system for 32-bit CPU design. The 64-bit OS is designed for 64-bit CPUs. The operating system is only a platform between hardware and application software. Our CPU ranges from 8-bit to 16-bit to 32-bit and 64-bit.

Background:

The computer memory is 8 GB, and the 32-bit win 7 32-bit version is installed. The system recognizes the memory as 3.5 GB, which should be 4 GB, because GB memory is allocated to the video memory.

The author is very painful.Hacker hackerA single 8 GB was instantly castrated with 4 GB. In order to make the best of its usage and taste, we have installed Windows 8 64-bit edition on another partition.

  • Memory condition in Windows 7 (x86:

  

  • Memory condition in Windows 8 (x64:

Problem:

When the 8 GB memory is fully enabled and the Windows 8 Metro interface is displayed, a problem suddenly emerges in my mind:Whether the 8 GB memory in a 64-bit system can be fully used by 32-bit programs.

Lab environment:
  • Windows 7 Ultimate (x86)
  • Windows 8 Professional (x64)
  • Visual Studio 2010 C ++ compiles a 32-bit console application
    • Apply for memory from the system in GB
    • Compile in 32-Bit mode
  • Main function code:
    • 1 // cpp_memorystudy.cpp: defines the entry point for the console application. 2 // 3 4 # include "stdafx. H "5 # include <iostream> 6 using namespace STD; 7 8 int _ tmain (INT argc, _ tchar * argv []) 9 {10 int A = 5; 11 int mem_size = 0; 12 const int gigabtye = 1024*1024*1024 * sizeof (char); #1 GB memory 13 int * P = NULL; 14 cout <"Please input how many GB memoroy you want allocate:" <Endl; 15 CIN> mem_size; 16 p = (int *) malloc (gigabtye * mem_size ); 17 if (null = P) 18 {19 cout <"allocate memory error" <Endl; 20} 21 else22 {23 cout <"succeed allocate memory" <Endl; 24} 25 getchar (); 26 getchar (); 27 return 0; 28}
  • Program Interface

  • Run in win 7 (1 GB memory for test application)OK)

  • Run in win 8 (test application 1 GB memory OK)

  • Run Windows 8 (3 GB memory for a single process test (total memory> 4 GB) fail)

  • Win 8 (multiple 32-bit processes apply for memory in 64-bit systems> 4 gb OK) -- this idea came to mind when discussing with friends. After testing it, we can

Conclusion:
  • According to the preliminary experiment results, a 32-bit program does not have the ability to use 4 GB + memory in a 64-bit environment.
  • You can apply for more than 4 GB memory for multiple 32-bit programs,
  • Another interesting phenomenon is that when I apply for a memory larger than 4 GB, sometimes the memory is displayed as successful, but it is not updated in the resource manager, proving that it is still unsuccessful, the reason for protection or other reasons still need to be further explored, which will be the subject matter of the next chapter.
  • The 64-bit system is only capable of running more single 32-bit programs for users who run 32-bit programs all the year round, 32-bit programs are still not capable of addressing 4 GB + in 64-bit Systems
    • In layman's terms, it is to expand the warehouse capacity so that it can put down more goods.
Future research ideas:
  • Recompile the above program in a 64-bit environment to study memory usage
  • The 32-bit Linux Ubuntu system supports 8 GB memory. I will test the addressing capability of a single program.
  • For 32-bit server systems that support 64 gb ram, such as Windows Server, How much memory can a single program use?

The above are some superficial understandings of the author. More research and arguments are yet to be discussed. I will continue to follow up on this topic and welcome you to join the discussion on this topic.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.