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 / .NET Framework / CLR / September 2003

Tip: Looking for answers? Try searching our database.

Memory Management

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Manish Parikh - 05 Sep 2003 12:42 GMT
Hi All

A Show Stopper problem in our application

we have a DLL which exposes some objects collections  in terms of get and
set properties. The objects have very heavy memory footprints (beyond 2gb)
we want to have the funcionality that if the memory usage goes beyond a
certain threshold limit we persist the content of these objects in hard disk
and destroy them to free up the memory.

Problem is, the instance to these objects will be created in the
Applications using this component. Can we free up the memory by destroying
these objects even if they are being refrenced from the client application?

Any Leads / Suggestions are most welcome

Regards,

Manish
Anthony Moore - 06 Sep 2003 00:44 GMT
This is an interesting general design-pattern question, and not really
CLR-specific. The CLR does not have some magic way of doing this without
creating some sort of wrapper class. So you will need to create a public
wrapper class with all the APIs of the object, but it should defer to an
internal object that  is only created on demand. It means you have to write
a lot of scaffolding code depending on how many properties and methods
these classes have, and it will cost a little bit of performance, but it
sounds like it is worth it for you in this case for the working set. To
minimize that, the objects could be structured into sub-objects, with the
top-level object having just a few properties.

The CLR does offer you one magic trick for dealing with the memory here,
which is to use the System.WeakReference class. If your wrapper class uses
a WeakReference instead of a regular object reference to manipulate the
internal object, the GC itself will clean it up if memory is getting really
tight. This makes the implementation a lot simpler for you.

I hope this helps.

--------------------
| From: "Manish Parikh" <parikh__manish@hotmail.com>
| Subject: Memory Management
[quoted text clipped - 30 lines]
|
| Manish
Manish Parikh - 06 Sep 2003 10:15 GMT
Many Thanks Anthony ! for the insight. For now i am going to work with
System.WeakReference option because of the Schedule constraints

Regards,

Manish

> This is an interesting general design-pattern question, and not really
> CLR-specific. The CLR does not have some magic way of doing this without
[quoted text clipped - 52 lines]
> |
> | Manish

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.