System.OutOfMemoryException when viewing graphs or saving a model

  Applies To 
  Product(s): Bentley WaterGEMS
  Version(s): 08.11.03.19
  Area:  General
  Original Author: Jesse Dringoli, Bentley Technical Support Group

Problem

The following error appears when trying to save a model. Another symptom is that the .wtg file becomes extremely large (several hundred megabytes or even a gigabyte or more in size):

---------------------------
OutOfMemoryException Details
---------------------------
Press Ctrl-C to copy details to clipboard:

System.OutOfMemoryException: Exception of type
'System.OutOfMemoryException' was thrown.

at System.String.GetStringForStringBuilder(String value, Int32
startIndex, Int32 length, Int32 capacity)

at System.Text.StringBuilder..ctor(String value, Int32 startIndex,
Int32 length, Int32 capacity)

at Haestad.Framework.Manager.GraphElement.WriteSettings(IStorageXmlWr
iteStream aisxws)

at
Haestad.Framework.Manager.GraphElement.WriteElement(IStorageWriteStream
astream)

at
Haestad.Framework.Manager.GraphElementManager.Write(IStorageWriteStream
astream)

at
Haestad.Support.Storage.XmlStorageFileBase.WriteStorageAtom(IStorageAtom
aatom)

at
Haestad.Support.Storage.XmlStorageFileBase.WriteElement(IStorageElement
aelement)

at Haestad.Support.Storage.StorageFileBase.Write(IStorageElement
aelement)

at
Haestad.Support.Storage.StorageManagerBase.Write(IStorageWriteContext
acontext)

at Haestad.Framework.Application.StorageProjectFileBase.Write()

at
Haestad.Framework.Application.DomainSettingsFile.Save(ProjectProperties
app)

at Haestad.Framework.Application.ProjectBase.Save(ProjectProperties
app)

at Haestad.Framework.Windows.Forms.Forms.HaestadParentForm.SaveProjec
t(IProject aiproject)

at Haestad.Framework.Windows.Forms.Forms.HaestadParentForm.SaveCurren
tFile()

at Haestad.Drawing.Control.Forms.GraphicalDrawingParentForm.menuButto
nItemFileSave_Activate(Object sender, EventArgs e)

at TD.SandBar.ToolbarItemBase.OnActivate()

at TD.SandBar.ButtonItemBase.OnActivate()

at TD.SandBar.ButtonItem.OnActivate()

at TD.SandBar.ToolBar.OnItemRelease(ToolbarItemBase item, Point
position)

at TD.SandBar.ToolBar.OnMouseUp(MouseEventArgs e)

at System.Windows.Forms.Control.WmMouseUp(Message& m,
MouseButtons button, Int32 clicks)

at System.Windows.Forms.Control.WndProc(Message& m)

at TD.SandBar.ToolBar.WndProc(Message& m)

at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message
& m)

at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message
& m)

at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)
---------------------------
OK
---------------------------


Problem ID#: 82369

Solution

This error may be due to a corrupt .wtg file. The size of the .wtg file should be relatively small (typically 50 KB - 5 MB) so the large size indicates extra data that the program was not designed to handle. In at
least one case, this extra data was related to graph series options.

1) Import the model database via File > Import > WaterGEMS Database (or select "Database Files" from the "Files of type" field in the File Open dialog) and ensure that the error no longer occurs.

*Note: You will need to rebuild your presentation settings (the information stored in the .wtg file), which consists of color coding, annotations, graphs, etc.

2) If the size of the .wtg file becomes bloated again, the problem could be related to your default chart options. In this case, try opening a graph, click the chart options button at the top and choose "reset factory defaults". Then, click "Save chart options as default", then "apply default chart options". You will have to do this for all your graphs.

*Note: After you make these changes you should be able to create the defaults again on your chart options if you choose to do that.

Anonymous
Recommended
Related