Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / July 2004

Tip: Looking for answers? Try searching our database.

Out of Memory Exception

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jack Wright - 27 Jul 2004 08:48 GMT
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
cody - 27 Jul 2004 09:55 GMT
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.

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu  || http://www.deutronium.tk
> Dear All,
>    I am getting Out of Memory exception sometimes while executing this code...
[quoted text clipped - 15 lines]
> Many Regards
> Jack
Herfried K. Wagner [MVP] - 27 Jul 2004 11:59 GMT
* sunil@volcanomail.com (Jack Wright) scripsit:
>    I am getting Out of Memory exception sometimes while executing this code...
> wot am I doing wrong here....
[quoted text clipped - 5 lines]
>     SizeF stringSize = new SizeF();
>     stringSize = oGraphics.MeasureString(sDummyString, sGridFont);

\\\
oGraphics.Dispose()
///

>     return ((int)stringSize.Width + 10);

Signature

M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.