Skip to main content

Document Hibernation

  • 2 minutes to read

Overview

At the server DocumentManager object level, DevExpress Office components (RichEdit and Spreadsheet) can automatically free server operative memory (RAM) by hibernating inactive open documents. Document hibernation is disabled by default.

If you enable document hibernation, open documents that remain idle for a certain period are released from server memory and saved to the server file system at a specific path. This reduces server memory consumption and prevents the loss of unsaved document changes even if planed IIS process recycling occurs.

API

The following hibernation settings are available through the API exposed by the DocumentManager object.

Property Name

Description

EnableHibernation

Switches the hibernation functionality on or off. The default value is false.

HibernationStoragePath

Specifies the path to the server directory where open documents hibernate after the idle timeout period expires.

HibernateTimeout

Specifies the idle timeout period before an open document is hibernated. The default value is TimeSpan.FromHours(1).

If an end user interacts with a hibernated document, the document is restored from the file to the server’s RAM. Note that the Spreadsheet component looses the Undo/Redo history after hibernation.

HibernatedDocumentsDisposeTimeout

Defines the timeout value that specifies how long hibernated documents are stored on the server before disposal. The default value is TimeSpan.FromHours(24).

After this timeout period has passed, a document file stored in HibernationStoragePath is deleted, and all unsaved end-user document changes are lost.

HibernateAllDocumentsOnApplicationEnd

Specifies whether or not all open documents should be hibernated.

You should specify hibernation in the Application_Start handler in Global.asax. In this instance, even after a server fails, you are not required to reload the page with the RichEdit or Spreadsheet component - end users can continue to work with the open document. Each subsequent request will raise the Application_Start handler and define hibernation settings.

Example

The following code example demonstrates how hibernation settings can be defined in the Application_Start method. Some of the settings are optional.

using DevExpress.Web.Office;

void Application_Start(object sender, EventArgs e) {
    // Code that runs on application startup
    DocumentManager.HibernationStoragePath = Server.MapPath("~/App_Data/HibernationStorage/"); //Required setting
    DocumentManager.HibernateTimeout = TimeSpan.FromMinutes(30); //Optional setting
    DocumentManager.HibernatedDocumentsDisposeTimeout = TimeSpan.FromDays(1); //Optional setting
    DocumentManager.HibernateAllDocumentsOnApplicationEnd = true; //Optional setting
    DocumentManager.EnableHibernation = true; //Required setting to turn the hibernation on
}
See Also