Citrix
Include legacy content

Archive: FAQ - Virtual Memory Optimization Feature

  • CTX106023
  • Created On  Apr 25, 2005
  • Updated On  Jun 18, 2014
  • 16 found this helpful
  • Article
  • Topic : Storage, Third Party, Performance
This article is no longer maintained, its content refers to a discontinued product and may be out of date. Refer to the Discontinued Product Lifecycle or Active Citrix Product pages for more information on support schedules.

Summary

Virtual Memory Optimization is a feature in Presentation Server 4.0 and later. The following questions and answers explain the benefits and inner workings of the feature.

Q: What is Virtual Memory Optimization?

A: It is a feature designed to decrease Virtual Memory consumption of applications and improve application initialization time.

Q: What Editions of Presentation Server support Virtual Memory Optimization?

A: Presentation Server 4.0, 4.5, XenApp 5.0, and later, Platinum and Enterprise Editions with Platinum or Enterprise Edition license files on the license server.

Q: Why is Virtual Memory Optimization necessary?

A: DLLs are designed to be shared by all applications, so that only one instance of a DLL is needed in memory (RAM) regardless of how many applications are using that DLL. When an application initializes and loads its DLL into its view of memory (the virtual memory), there is a chance that the base memory address where it is attempting to load that DLL may already be occupied by another DLL. This event of attempting to load two DLLs at the same base memory address is called a collision. When a collision occurs, the DLL has to be relocated to an available base memory address. When this happens, the DLL can no longer be shared by other applications, and hence this takes up more actual memory, which also increases the amount of paging that the system must do and slows down overall performance. The loader then has to update all the hard-coded pointers in the DLL to reflect the new base address, which slows application load-time.

Q: What files and executables are used with Virtual Memory Optimization and where are they located?

A: All files related to this feature are located in Program Files\Citrix\Server Resource Management\Memory Optimization Management. Below is a description of these files:

CtxSFOsvc.exe - Monitors all DLLs on a server to find where collisions are occurring

CtxBace.exe - Optimizes the DLLs that are having trouble, by calculating a new base memory address and copying and changing the DLL to load at that address.

CtxTest.DLL - Responsible for testing all DLLs that have been modified to make sure that they still work

Repair.SFO - This is an XML file that has information about problematic DLLs found on a system that will be modified by the CtxBace.exe process.

Bind ####.SFO - Log files that list the DLLs that were optimized and how much virtual memory was saved because of the optimization

Q: How does Virtual Memory Optimization work?

A:

  • The feature is enabled in the Presentation Server Console under the farm or server properties in the Memory/CPU Utilization Management section. Once the feature is enabled, the Citrix Virtual Memory Optimization service starts automatically. If the feature is disabled the service stops automatically.
  • Once the feature is enabled, the Citrix Virtual Memory Optimization service, which is tied to the CtxSFOSvc.exe process, monitors all DLLs on the system to find out where DLL collisions and relocation are occurring. It writes the name of these DLLs to a file called Repair.sfo located in Program Files\Citrix\Server Resource Management\Memory Optimization Management\Data.
  • At a scheduled time every day and during system startup, CtxBace.exe reads the Repair.sfo file and optimizes the DLL to prevent collisions from occurring the next time the DLL is loaded.
  • After CtxBace.exe optimizes the DLL, CtxTestDLL.exe loads the DLL to ensure that the DLL is still functional.
  • Other than rebasing DLLs, the optimization process also involves Binding executables to make application initialization time faster.

Q: What is DLL Rebasing?

A: Rebasing changes a DLL so that it loads at an optimal base memory address to avoid collisions and relocations.

Q: What is Binding?

A: In order to explain what the Binding process does, here is a bit of background on how applications work. When an application initializes, the executable loads various DLLs that it needs at run-time. DLLs export functions that are made available to the application executable. However, in order for the executable to make use of a DLLs exported functions, it needs to look at the export table of that DLL to find the memory address where the functions are located.

The Binding process modifies the executable so that it has the memory address of these functions in advance. By having the address of these functions in advance, the executable does not have to read the DLLs export table. It just loads the DLL and goes directly to the memory address of that function at run-time.

Q: When does the actual optimization process occur?

A: The optimization occurs when the Ctxbace.exe process is running. That process can be seen in Task Manager. This process runs once when scheduled, then exits. It can be configured to run at a specified time in the Presentation Server Console under farm properties, Memory Optimization. By default the process is scheduled to run under the system account but it can be modified to run under another account in the Console.

Q: What is actually occurring during the optimization process?

A: After the Ctxbace.exe process reads the Repair.SFO file to see which DLLs to optimize, it makes a temporary copy of the DLL, calculates a potential safe base memory address, the CtxTestDLL program loads the new modified DLL to make sure it still works, then Ctxbace places the new modified DLL into an Alternate Data Stream of the original file. The original DLL is unchanged.

Q: What is the Repair.sfo file used for?

A: Repair.sfo is an XML file that is written-to by the Citrix Virtual Memory Optimization service (CtxSFOSvc.exe). This file contains a list of all .exes and DLLs that are to be optimized. It is located in [Program Files\Citrix\Server Resource Management\Memory Optimization Management\Data].

Q: What is an Alternate Data Stream?

A: They are hidden files that are attached to visible ones. The size of the original file stays the same; the only thing that changes is the modified date of the original file. The optimization process makes a copy of the original file, changes the base address on the copy and puts the modified copy into an Alternate Data Stream attached to the original file.

Q: How does the operating system determine whether to load the original file or the modified file located in the Alternate Data Stream?

A: There is a file filter driver that located in [Program Files\Citrix\Server Resource Management\Memory Optimization Management\System32\Drivers]. This file filter driver intercepts all calls to the file system. The driver checks to see if an Alternate Data Stream has been added to the file and if so it sends the alternate data stream back to the operating system.

Q: What if an application is affected by Virtual Memory Optimization?

A: If an application is not functioning correctly after being optimized by this feature it can be placed on the application exclusion list. The exclusion list is located in the Presentation Server Console under the farm properties in the Memory Optimization section. All applications placed on the exclusion list will be in the registry of each server under HKEY_LOCAL_MACHINE\ SOFTWARE\ Citrix\ SFO <ComponentExclusionList> or <ProcessExclusionList>. If you do not want to have the feature optimize a particular application it can also be placed on this list.

Note: DLL files added to the exclusion list using Citrix Management Console > Farm Properties > Memory Optimization are added to the ProcessExclusionList in the registry, but not the ComponentExclusionList. Therefore, the file is not excluded from memory optimization. Manually add the DLL’s to the ComponentExclusionList in the registry. Citrix may address this issue in a future release.

Q: Is there a list of applications that will not work with Virtual Memory Optimization?

A: While there may be other applications that do not work with this feature, the default exclusion list contains all known applications and DLLs that have been problematic in the past. This default exclusion list is in the registry location mentioned above.

Q: Are there types of applications that Virtual Memory Optimization is not designed to work with?

A: Yes. Applications that have digitally signed components, applications whose DLLs are protected by Windows Rights Management, and any application whose executable programmatically checks the DLL after it has been loaded.

Q: If I stop the Citrix Virtual Memory Optimization process, can that stop the optimization if it is has already begun?

A: No. This service is only monitoring the DLLs on the system and writing the name of the problematic .exe and DLL to the Repair.sfo file. Once they have been written to the Repair.sfo file when the Ctxbace.exe process runs it optimizes what is in the file. By stopping the service you are only stopping any future writes to the Repair.sfo file.

Q: How often should the optimization process run?

A: It is best to configure the optimization to run daily at an off peak time. You can configure this in the Presentation Server Console under Farm properties > Memory Optimization.

Q: Are there any log files that tell what DLLs or executables have been optimized?

A: Yes. After every optimization a log file is created that reports everything that was optimized or attempted to be optimized during the last optimization session. The file is called “Bind 38415.696366.SFO” and is located in [Program Files\Citrix\Server Resource Management\Memory Optimization Management\Data\Archive]. The logs allow an administrator to see for themselves how much savings each application or DLL gets them when it is rebased. There can be numerous log files created in this directory over time. They can be deleted or archived to another location to save disk space.

Q: Is the Citrix Virtual Memory Optimization service dependent on the IMA service?

A: The “Citrix Virtual Memory Optimization” is stopped and started by the IMA service. When looking at the properties of the service in the Services Manager you will see that it is set to manual because it is controlled by the IMA service. However if the IMA service fails to start, the “Citrix Virtual Memory Optimization” will not be automatically started either. The service can be manually started in the Services manager. If you restart the IMA service it will not restart the “Citrix Virtual Memory Optimization” service.

Q: How can you tell how much virtual memory has been saved by the Virtual Memory Optimization feature?

A: An administrator can use the Report Center in the Access Suite Console to create run a Virtual Memory Optimization report that details how much virtual memory has been saved by using this feature. This report does not require a connection to a summary database. It pulls its information from the Bind ######.sfo log files located in the \Archive directory.

More Information

CTX106699 – [Document Not Found]

CTX109222 – [Document Not Found]

CTX109639 – Hotfix PSE400R01W2K038 - For Citrix Presentation Server 4.0 for Windows 2000 Server

CTX109620 – Hotfix PSE400R01W2K3055 - For Citrix Presentation Server 4.0 for Windows Server 2003

CTX117669 – How to Disable the CtxAltStr.Sys Driver


Share your comments or find out more about this topic

Citrix Forums

Languages

N/A

| Terms of Use | Privacy | Governance