Out of Memory Exception

  • Thread starter Thread starter Jack Wright
  • Start date Start date
J

Jack Wright

Dear All,
I am getting Out of Memory exception sometimes while executing this code...
wot am I doing wrong here....
private int GetStringLength(string StringToMeasure)
{
System.Drawing.Graphics oGraphics = this.CreateGraphics();
Font sGridFont = _MyGrid.Font;
string sDummyString = StringToMeasure;
SizeF stringSize = new SizeF();
stringSize = oGraphics.MeasureString(sDummyString, sGridFont);
return ((int)stringSize.Width + 10);
}

Please help...

TALIA

Many Regards
Jack
 
I can only imagine that something is wrong with the font or you pass an
extremely long string to that method.
If both doesn't apply I guess it is a bug.
 
* (e-mail address removed) (Jack Wright) scripsit:
I am getting Out of Memory exception sometimes while executing this code...
wot am I doing wrong here....
private int GetStringLength(string StringToMeasure)
{
System.Drawing.Graphics oGraphics = this.CreateGraphics();
Font sGridFont = _MyGrid.Font;
string sDummyString = StringToMeasure;
SizeF stringSize = new SizeF();
stringSize = oGraphics.MeasureString(sDummyString, sGridFont);
\\\
oGraphics.Dispose()
///

return ((int)stringSize.Width + 10);
 
Back
Top