Virtual Memory Optimization Feature

Citrix states in their article: CTX106023

Document ID: CTX106023, Created on: Apr 25, 2005, Updated: May 2, 2006

Products: Citrix Presentation Server 4.0 for Microsoft Windows 2000, Citrix Presentation Server 4.0 for Microsoft Windows 2003, Citrix Access Essentials 1.0, Citrix Presentation Server 4.0 x64 Edition

Summary

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

Q: What is Virtual Memory Optimization?

It is a MetaFrame Presentation Server 4.0 feature designed to decrease Virtual Memory consumption of applications and improve application initialization time.

Q: What Edition of MetaFrame supports this feature?

MetaFrame Presentation Server 4.0 Enterprise Edition with an Enterprise Edition license file on the license server.

Q: Why is this feature necessary?

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 occurs, 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 this feature and where are they located?

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 bases 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 are to 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?

1. 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 is started automatically. If the feature is disabled the service will stop automatically.

2. 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.

3. 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.

4. After CtxBace.exe optimizes the DLL, CtxTestDLL.exe loads the DLL to ensure that the DLL is still functional.

5. Other than rebasing DLLs, the optimization process also involves Binding executables to make application initialization time faster.

Q: What is DLL Rebasing?

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

Q: What is Binding?

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 doesn’t 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?

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?

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?

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?

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?

There is a new file filter driver that is added to MPS4.0 called CtxAltStr.sys 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 this feature?

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 or . If you do not want to have the feature optimize a particular application it can also be placed on this list.

Note: DLL’s files added to the exclusion list via the Citrix Management Console > Farm Properties > Memory Optimization will be 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 this feature?

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 are types of applications that this feature is not designed to work with?

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?

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 will optimize 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?

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?

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]. They 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 located to save disk space.

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

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?

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 – Application Fails to Launch Properly After Installing Citrix Presentation Server 4.0



Primary links

Custom Search

Who's new

  • Preatercelepe
  • Kxtuzjgv
  • Maitacewwisat
  • abnonsoks
  • themopoty

Who's online

There are currently 0 users and 5 guests online.

KrissysCorner.com RuthSwensonLaw.com CreativeLizardProductions.com

DISCLAIMER:

None of this has anything to do with us, someone else is responsible for the entire thing, and we have no idea who or why. We do not know anything about it. It may be alien life forms for all we know: we haven't a clue. You cannot blame us for anything that may result from your visit. That was entirely your own personal choice, made by you of your own volition, and without our knowledge. We do not, after all, have any control over you and cannot by any stretch of the imagination be expected to accept or acknowledge, be it legally or morally, any accountability for decisions made by you on an independent basis, utilizing your own free will, and without our intervention. We are therefore in no way, shape, or form answerable to anyone for any consequences arising from the aforementioned or indeed any other actions, similar or otherwise, because it was not us that did, or did not do anything. It is not even remotely our fault, and we are in no way prepared or willing to accept any liability, not even slightly, ever. We are, in fact completely and utterly blameless, in that it is definitely not our concern, and no blame can possibly be laid at our doorstep, even if we had one, the possession of which we hereby reserve as being entirely our own free choice. The onus is not on us at all, and furthermore, never has been. The entire matter is wholly beyond our control, and completely out of our hands, each of which are washed scrupulously clean of the whole business. We are not accountable for anything at all, and we hereby categorically deny all responsibility for all that has ever, or will ever happen. Our innocence is therefore wholly beyond doubt and absolutely unimpeachable, and so cannot, under even the remotest or unlikeliest circumstances, be brought into question. By clicking either on a link on this site, clicking on a link that leads to this site, or by arriving at this site by natural or supernatural means, you are in effect accepting responsibility for the fact that it is all entirely your own fault, down to the most miniscule detail, and that you are wholly accountable for whatever outcome may arise as a consequence of the aforementioned action or actions insofar as they were undertaken personally by you on an entirely voluntary basis and without any persuasion, coercion or influence from any party or parties other than yourself. Don't come sniveling to us, we are only figments of your imagination. I also agree that if I am ever with a contributor to this website during mealtimes I agree to pay for any super-sizing of their meal, or at least a nice dessert or one of those foo-foo drinks with an umbrella or a monkey. By admitting to have seen the worthless spineless drivel on this website (also known as content)

I Agree Wholeheartedly and Without Reservation to the above. (Except maybe for that part about the monkey.)

All Your Base Are Belong To Us.

Soylent Green Is People!

Never make a bet with a Sicilian when Death is on the Line!

No. Really, I do agree.