In-depth SQL Server 2000 memory management mechanism (1)

zhaozj2021-02-17  54

In-depth SQL Server 2000 memory management mechanism

Http://msdn.microsoft.com/data/default.aspx?pull=/library/en-us/dnsqldev/html/sqldev_01262004.asp

Ken Henderson

Microsoft Corporation

Remarks: Ken Henderson elaborates the internal mechanism of SQL Server 2000 memory management from the developer's perspective

Introduction

In this column, we will explore SQL Server's memory management from a developer's perspective. So we will discuss the memory management mechanism of the API and the operating system of server memory management. How do they run? To explore SQL Server memory management in this novel way, you can make developers understand the priority, master of a product, we To understand how it is running and specific use.

Our first started research, including some basic principles for Windows memory management. Like all 32-bit Windows programs, SQL Server is also allocated, released, and universal memory management resources using Windows memory management mechanisms. That is, SQL Server and other Windows programs interact with the memory management resource provided by the Win32 API function and the operating system.

Because almost all SQLServer memory allocations are used using virtual memory (instead of stacks), most memory allocation code decomposes to finally adjust the Win32 Virtualallo and VirtualFree API functions. SQL Server reserves and submits virtual memory by calling the Virtualallo function, releases memory through the VirtualFree function.

Virtual memory and physical memory

In the series of X86 processors, Windows provides all programs to address 4GB virtual memory space. The so-called "virtual" means that this is not a traditional memory, which is just an implicit address segment without physical storage. Because only one program starts memory allocation, these address segments and physical allocation storage space are started. Moreover, these physical storage spaces do not require physical memory (not complete), usually disk space. It is clear that it should be in the system's virtual page file. That's why there are many programs (a 4GB virtual memory space for each program) can run on a machine with only 128M physical memory, just like each program assigns real memory. Windows transparently controls copying and reading data from the system page file, so the program can allocate more memory space than physical memory over the running machine and various programs can be all accessed. Physical memory.

4GB memory address space is divided into 2 pieces: user memory space and core memory space. By default, you can change the size of the default space through the Boot.ini file of the Windows NT Series operating system (such as: Windows NT, Windows 2000, Windows XP and Windows Server 2003), Windows NT Series, Windows 9X and Windows Me are not.

Figure 1. Windows Partitions A Process's Virtual Address Space INTO The User Mode (Application) And kernel mode (Operating system) Partitions.

Although each program accepts its own virtual memory space, system code and device driver code share a separate private virtual address space. Each virtual memory page is associated with a special processor mode. In order to meet all system pages, they can be accessed, and the processor must be a request mode. This means that the user's program is unable to access the core memory space, and the system must switch to core mode so that the memory space of the core mode can be accessed.

Program memory space adjustment

There is a / 3GB parameter in the boot.ini file that allows you to change the default restriction (this parameter is valid in Windows Advanced Server and Windows 2000 Data Center), which can be applied by sacrificing core memory space (low from 2G to 1G). The program's memory space increases from 2G to 3G. In Windows usage, this mechanism is called memory space adjustment or 4GT adjustment (4GT). You can pass the appropriate line in the [Operating Systems] area in the boot.ini file. Plus / 3GB parameters to adjust the application's memory space. For a general person, you can select the appropriate row of the [Operating Systems] area of ​​the box of the Boot.ini file to increase / 3GB or not / 3GB parameters to start the system. Warning: You can also start the system in Windows 2000 PROFESSIONAL and Windows 2000 boot files, but this only reduces the core memory space to 1GB but does not increase the application memory space. In other words, there is no Benefits from reducing core memory space

Note:

in

Windowsxp

with

Windows Server 2003

Provide a new startup parameter

/ Userva

,

Can

/ 3GB

Use of parameters

,

But allow you to have more excellent control

.

You can like

/ 3GB

Same

/ Userva

Parameter to

Boot.ini

In the file

. / Userva

Parameter ratio

/ 3GB

The advantage is

,

It allows you to specify the size of the memory address space to be assigned to the application

.

such as

: / Userva = 2500

The meaning is configuration

2.5g

Memory address space reserved to user memory space

1.5G

Leave to core memory space

.

Special Note

/ 3GB

The parameter can still be used separately.

.

转载请注明原文地址:https://www.9cbs.com/read-29090.html

New Post(0)