home *** CD-ROM | disk | FTP | other *** search
/ MacAdvocate 2 / apple-mac-advocate-ii-fall-1997.iso / mac / MacOS / Helpful Hints and FAQs / Apple Tech Info Library / Virtual Mem Diff. on Pwr Mac < prev   
Encoding:
Text File  |  1996-12-02  |  9.4 KB  |  131 lines  |  [TEXT/ttxt]

  1. Revised:       7/1/96
  2. Security:      Everyone
  3.  
  4. Virtual Memory: How It Differs On Power Macintosh (7/96)
  5.  
  6. ======================================================================
  7.  
  8. Article Created: 18 July 1994
  9. Article Reviewed/Updated: 01 July 1996
  10.  
  11. TOPIC -----------------------------------------------------------
  12.  
  13. Why is the RAM requirement lower for a program when virtual memory (VM) is running? When you do a Get Info on an application on a Power Macintosh you get an additional message that gives a lower memory requirement if you have virtual memory turned on. Since this still looks like RAM to the application, why is there a lower RAM requirement?
  14.  
  15. This article answers these questions and describes how you can reduce the memory requirements for Power Macintosh native applications that require large amounts of RAM, such as Microsoft Excel or Word.
  16.  
  17. DISCUSSION ------------------------------------------------------
  18.  
  19. Overview
  20. ========
  21.  
  22. With the introduction of Power Macintosh, virtual memory, the ability to assign part of a hard drive as if it were additional physical memory, gains advantages over previous systems. By enabling virtual memory, Power Macintosh computers are able to utilize a feature called file mapping, which can significantly reduce the amount of physical memory required to launch a native application. Enabling Virtual Memory reduces the overall memory requirements of large native Power Macintosh applications. After enabling Virtual Memory, the Application Partition is substantially smaller and the System Partition increases by a relatively small amount.
  23.  
  24. In a recent sampling of native Power Macintosh applications, we found the average RAM required to launch an application was almost 2 MB less when virtual memory was enabled.
  25.  
  26. In the past, the only reason to enable virtual memory was to simulate the addition of real memory to a system. With Power Macintosh, simply enabling virtual memory without adding any virtual space has the desirable effect of reducing the application RAM footprint.
  27.  
  28.  
  29. Excerpts from "Inside Macintosh: PowerPC System Software"
  30. =========================================================
  31.  
  32. Without Virtual Memory
  33. ----------------------
  34. When virtual memory is not enabled, the application's Stack (temporary data storage), Heap (dynamically allocated storage), and all Code Fragments (Executable PowerPC code) must load into the Application Partition, resulting in increased launch times and RAM requirements for large applications.
  35.  
  36. With Virtual Memory
  37. -------------------
  38. With Virtual Memory enabled, only the application's Stack and Heap load into the Application Partition, reducing the launch times and RAM requirements for native applications. The application's Code Fragments are then tracked by the Virtual Memory Manager, which only writes the Code Fragments to the System Partition when needed, resulting in fewer Code Fragments loaded into memory at one time.
  39.  
  40. As an additional benefit, the Operating System assumes the application's code section is always read-only, meaning that, when it’s time to remove some of the application's code from memory (to page in other code or data), the Virtual Memory Manager doesn’t need to write the code back to the hard disk. Instead, it simply purges the code from the System Partition and writes new code to the System Partition, reducing the time required to load applications code.
  41.  
  42. Virtual Memory Benefits
  43. -----------------------
  44. So, by enabling Virtual Memory you have these benefits:
  45.  
  46. • Reduce the RAM required for Application Partitions.
  47. • Increase the System Partition. (But, to a lesser extent than
  48.   the Application Partition)
  49. • Reduce the start up time for applications.
  50.  
  51.  
  52. How Virtual Memory on Works on 680x0 Macintosh
  53. ==============================================
  54.  
  55. On a 680x0 Macintosh, the Segment Loader loads as much of the application as possible into memory, which is dictated by both the amount of available memory and the application's heap size (set using the Finder's Get Info dialog). If you want to increase an 8 MB system to 12 MB by using Virtual Memory, the system creates a 12 MB space on disk. When instructions or data are accessed by the system, and are not resident in memory, a "page fault" occurs. A page fault causes the system to write the least recently used "page" to disk and then satisfies the page fault by "swapping" in the page which contains the required data. This mechanism is designed to keep the most frequently used pages in physical memory ("working set") and the least frequently used ones on disk. The task of keeping all the locations straight is the job of virtual memory and the Memory Management Unit (MMU).
  56.  
  57.  
  58. How Power Macintosh VM Is Different
  59. ===================================
  60.  
  61. With native applications on Power Macintosh, there is no Segment Loader. When virtual memory is disabled, applications are loaded into memory as a contiguous block. The amount of space required for all of the code in a single application can be quite large. However, Power Macintosh applications are written to a strict new specification for the types of data that reside in the data and resource forks. In particular, the data fork contains read-only data for the application, whereas the resource fork contains information that can be modified. This is an important distinction because these rules, with virtual memory enabled, let the Code Fragment Manager (CFM) take advantage of file mapping.
  62.  
  63. With file mapping active, only some of the resource fork needs to be loaded into memory. Items in the data fork of the application can remain on disk and will be "mapped" into memory by the CFM as needed. This has the advantage of dramatically reducing the amount of data that has to immediately copied into memory at application launch time.  Additionally, read-only items in the data fork can be trashed when a page fault occurs, rather than writing the old information out to disk. This reduces a write-read cycle, to a single read. This is why Power Macintosh virtual memory performance is improved over 680x0, even though the core code is unchanged.
  64.  
  65. The Modern Memory manager does not affect how the Virtual Memory Manager handles Code Fragments. So, enabling Virtual Memory and not enabling the Modern Memory has the same result.
  66.  
  67.  
  68. Virtual Memory Diagram
  69. ======================
  70.  
  71. The following diagram may be helpful in describing how Virtual Memory affects RAM requirements. The left column lists possible memory configuration for a Power Macintosh with three native applications with virtual memory enabled. The right column is for three native applications with virtual memory not enabled. The center column provides possible memory requirements.
  72.  
  73. Begin_Table
  74.  
  75. Power Macintosh with            Physical  Power Macintosh with
  76. Virtual Memory Enabled            RAM     Virtual Memory not Enabled
  77. ----------------------          -------   --------------------------
  78. System Software                   1MB     System Software
  79.   System Partition                ***       System Partition
  80.   Application A, Code Section 1   2MB     Application A Partition
  81.   Application B, Code Section 1   ***       Heap
  82.   Application C, Code Section 1   3MB       Stack
  83. Application A Partition           ***       Application A, Code Section 1
  84.   Heap                            4MB       Application A, Code Section 2
  85.   Stack                           ***       Application A, Code Section 3
  86. Application B Partition           5MB       Application A, Code Section 4
  87.   Heap                            ***     Application B Partition
  88.   Stack                           6MB       Heap
  89. Application C Partition           ***       Stack
  90.   Heap                            7MB       Application B, Code Section 1
  91.   Stack                           ***       Application B, Code Section 2
  92.                                   8MB       Application B, Code Section 3
  93.                                   ***       Application B, Code Section 4
  94.                                   9MB     Application C Partition
  95.                                   ***       Heap
  96.                                   10MB      Stack
  97.                                   ***       Application C, Code Section 1
  98.                                   11MB      Application C, Code Section 2
  99.                                   ***       Application C, Code Section 3
  100.                                   12MB      Application C, Code Section 4
  101.  
  102. End_Table
  103.  
  104. Because of file-mapping and the Code Fragment Manager, most Power Macintosh users will want to activate virtual memory. For those wishing to take advantage of increased memory space, Apple recommends setting virtual memory on Power Macintosh computers to 50% more than the amount of physical memory.
  105.  
  106. Example: If you have 8MB of RAM, set the system to 12 MB in the Memory
  107.          control panel.
  108.  
  109. Customers who want the highest performance possible, but still want the benefits of the reduced application footprint of file-mapping, can set virtual memory to the minimum amount of 1 MB more than physical RAM.
  110.  
  111. Example: If you have 8 MB of RAM, set the system to 9 MB in the Memory
  112.          control panel.
  113.  
  114.  
  115. Article Change History:
  116. 01 Jul 1996 - Added Fax Doc Word
  117. 21 Nov 1995 - Reviewed for technical accuracy.
  118. 14 Aug 1995 - Added Internet table formatting convention.
  119. 19 May 1995 - Made grammatical correction.
  120.  
  121. Support Information Services
  122.  
  123. Copyright 1994-96, Apple Computer, Inc.
  124.  
  125. ======================================================================
  126.  
  127. Created:       7/18/94
  128. Author:        52
  129. Source:        PTS
  130. Library:       TECHINFO
  131. Article ID:    TECHINFO-0015854