471,327 Members | 2,681 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,327 software developers and data experts.

Memory management question

Hi all,

I'm still learning about dispose()'ing of resources and i'm curious if
there is anything I should do in the following circumstance:

rtbBrowseEntryBody.SelectionFont = new Font(<font info>);

By using the 'new' keyword i'm allocating memory. Should I do anything
to free this memory after the section which needs it is finished? Or
should it just be left to GC? Or should I not be using such statements,
but something else.

Any help would be appreciated,

Paul

Jan 13 '06 #1
2 1002
In general, you do not need to worry about Dispose unless an object
implements IDisposable and has a Dispose method, or if you have an object you
are writing that holds onto unmanaged resources.

The Garbage Collector takes care of all this for you. When an object is out
of scope and is no longer referenced, the Garbage man sees it's been put out
to the street and picks it up.
Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Paul" wrote:
Hi all,

I'm still learning about dispose()'ing of resources and i'm curious if
there is anything I should do in the following circumstance:

rtbBrowseEntryBody.SelectionFont = new Font(<font info>);

By using the 'new' keyword i'm allocating memory. Should I do anything
to free this memory after the section which needs it is finished? Or
should it just be left to GC? Or should I not be using such statements,
but something else.

Any help would be appreciated,

Paul

Jan 13 '06 #2
On Fri, 13 Jan 2006 12:35:18 -0600, Paul <Ge**********@gmail.com> wrote:
Hi all,

I'm still learning about dispose()'ing of resources and i'm curious if
there is anything I should do in the following circumstance:

rtbBrowseEntryBody.SelectionFont = new Font(<font info>);

By using the 'new' keyword i'm allocating memory. Should I do anything
to free this memory after the section which needs it is finished? Or
should it just be left to GC? Or should I not be using such statements,
but something else.

Any help would be appreciated,

Paul


General rule I've heard and follow is don't get involved in
disposing/finalizing unless it's a large, memory-intensive object where
it'd be beneficial to reclaim memory as quickly as possible, or if it's a
reference to an unmanaged component.

--
Craig
Microsoft MVP - ASP/ASP.NET
Jan 13 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by trialproduct2004 | last post: by
13 posts views Thread by Vijay | last post: by
3 posts views Thread by Jim Land | last post: by
9 posts views Thread by benoit808 | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.