Memory space manipulating in Java(Section two:Process Memory Model on AIX part two-Default Memory Model)

来源:互联网 发布:图片文字转换软件 编辑:程序博客网 时间:2024/05/16 07:45
 Default 32-bit Process Memory Model
32-bit applications on AIX have an address space of 4 GB (2**32=4G), with virtual addresses ranging from 0x00000000 through 0xFFFFFFFF. AIX divides this address space into 16 independent segments; each is a 256 MB chunk and addressed by a separate segment register. You can identify a segment from the high-order nibble of any virtual address. (e.g. 0xEFFFFFFF, the E follows the x indicates this address belongs to E segment)
 Here one thing I want to emphasize is that each 32-bit can request a virtual address space, whose maximum size is 4GB, it doesn’t mean the size of virtual address space is being limited with 4GB. In a 32-bit system, hardware provides you with a virtual address space whose size can up to 252 (1000TB). But pay attention to that the distinct 4GB address space contains parts like Shared-library text segment, Kernel segment which are not private to your process,so it means in your own program, virtual memory space which you can ask for will always less than 4GB.
Below there is a picture shows how each segment is used in the default 32-bit process memory model.
(Note that every 32-bit application will have its own address space in this model or the other two we are going to discuss in the following section.)
To briefly summarize the usage of each segment:
1) The first segment, 0x0, is reserved by the system for the kernel text and data, so access from the user process to the segment 0x0 is prohibited.
2) The 0x1 segment contains user process text, which is the code of the user process. If multiple processes are running the same executable, all these processes will have access to the same segment. There will be only one instance of the text pages for that
executable file on the system. (You should know the Java executable file is living here)
3) The 0x2 segment contains user data, heap, and stack. This segment is private to the user process, and is the most interesting one for our discussion of Java process. We will explain it in more detail in the following section.
 Notice that Data & Heap & Stack areas allocated on 0x2 segment are used by malloc(), subroutines which allows a process to dynamically allocate chunks of memory from its process heap. (There are still calloc(), realloc(), free() and similar functions can be used)
4) The 0xD segment contains shared library text. All shared library modules are mapped into this segment, which is shared by all 32-bit user processes. For instance, Java application which uses IBM MQ Workflow native API will have the C/C++ module allocated on this segment.
Path in hard disk: /usr/lpp/fmc/lib/libfmcjdint.a
Location in Virtual Memory space: 0xD43600A0
Note that any other running processes which want to use the same module could not load it into memory again.
5) The 0xF segment contains per-process shared library data, and is also private to the user process. Here private mean that it can not be accessed from other processes even contains the same content as others.
6) Segments 0x3 - 0xC and 0xE are reserved for the user process to attach to the process address space if the process calls shmat() or mmap() routines to allocate shared memory segments. Unless the users specify an address in shmat() or mmap() calls, these segments are allocated in order, starting from segment 0x3 towards higher number addresses. In general, hard coding the attaching memory address is bad programming practice, and hinders the portability of the application. The maximum possible shared memory in this model is 11 segments, which is 2.75 GB.
Note: This is decided by the value of key word o_maxdata, which is use as a boundary
In case of the default process memory model, its value is 0x00000000, which means user program data can use 0 (the 0 follows 0x) segment while all segments from 3 through C can be used for shared memory.
原创粉丝点击