Click here to Skip to main content
15,889,216 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
QuestionIs there a way to handle OutOfMemory exceptions? Pin
sarabjs30-Jan-06 8:40
sarabjs30-Jan-06 8:40 
AnswerRe: Is there a way to handle OutOfMemory exceptions? Pin
Guffa30-Jan-06 9:36
Guffa30-Jan-06 9:36 
AnswerRe: Is there a way to handle OutOfMemory exceptions? Pin
likefood30-Jan-06 11:07
likefood30-Jan-06 11:07 
GeneralRe: Is there a way to handle OutOfMemory exceptions? Pin
sarabjs1-Feb-06 6:14
sarabjs1-Feb-06 6:14 
AnswerRe: Is there a way to handle OutOfMemory exceptions? Pin
Ingo31-Jan-06 3:18
Ingo31-Jan-06 3:18 
GeneralRe: Is there a way to handle OutOfMemory exceptions? Pin
Dan Neely31-Jan-06 3:34
Dan Neely31-Jan-06 3:34 
GeneralRe: Is there a way to handle OutOfMemory exceptions? Pin
Ingo31-Jan-06 4:12
Ingo31-Jan-06 4:12 
GeneralRe: Is there a way to handle OutOfMemory exceptions? Pin
Dave Kreskowiak31-Jan-06 5:13
mveDave Kreskowiak31-Jan-06 5:13 
The .NET GC is self-tuning. It runs on both a semi-regular (self-adusted) schedule and on-demand when either the applications calls for it or the operating system does and wants memory returned. Memory is never released "improperly" as you call it. The GC tries, and does a very good job, at keeping a resonably sized pool of memory available to the application for future allocations. Like I said, the GC is self-tuning and can only improve it's allocation strategy by over-estimating what it needs to start with then watching how your application allocates and releases memory.

But, yes, the GC is a bit lazy when application activity is low, and for good reason. In order for the GC to run, the threads of your application must be stopped before the collection takes place. This is because objects in memory can be moved by the GC to compact and defrag the heaps and pointers to those objects must be updated to reflect their new locations. This cannot be done while the code is still running! So, yeah, the GC tries to be as lazy as possible, giving your app more time to execute.

Garbage Collection and object allocation, when dealing with the Managed Heap, goes VERY, VERY fast. It slows down considerably if memory has to be allocated from the system first, adding it to the Managed Heap.

BTW, this is all documented on MSDN:
Programming for Garbage Collection[^]
Garbage Collection: Automatic Memory Management in the Microsoft .NET Framework[^]
Garbage Collection—Part 2: Automatic Memory Management in the Microsoft .NET Framework[^]
Improving .NET Application Performance and Scalability[^]


RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

AnswerRe: Is there a way to handle OutOfMemory exceptions? Pin
RajeshGuptha2-Feb-06 7:47
RajeshGuptha2-Feb-06 7:47 
AnswerRe: Is there a way to handle OutOfMemory exceptions? Pin
sarabjs3-Feb-06 10:03
sarabjs3-Feb-06 10:03 
QuestionHow can I flush window events? Pin
swcrissman30-Jan-06 3:37
swcrissman30-Jan-06 3:37 
AnswerRe: How can I flush window events? Pin
kasik30-Jan-06 4:38
kasik30-Jan-06 4:38 
GeneralRe: How can I flush window events? Pin
swcrissman30-Jan-06 5:21
swcrissman30-Jan-06 5:21 
QuestionRequired .NET Profiler Pin
RajeshGuptha30-Jan-06 1:00
RajeshGuptha30-Jan-06 1:00 
AnswerRe: Required .NET Profiler Pin
tarasn30-Jan-06 4:48
tarasn30-Jan-06 4:48 
AnswerRe: Required .NET Profiler Pin
Robert Rohde30-Jan-06 20:24
Robert Rohde30-Jan-06 20:24 
GeneralRe: Required .NET Profiler Pin
RajeshGuptha2-Feb-06 7:58
RajeshGuptha2-Feb-06 7:58 
QuestionInstall Framework 2.0 SDK with Visual Studio 2003 Pin
nikolag29-Jan-06 21:35
nikolag29-Jan-06 21:35 
AnswerRe: Install Framework 2.0 SDK with Visual Studio 2003 Pin
Dave Kreskowiak30-Jan-06 1:32
mveDave Kreskowiak30-Jan-06 1:32 
GeneralRe: Install Framework 2.0 SDK with Visual Studio 2003 Pin
nikolag31-Jan-06 21:45
nikolag31-Jan-06 21:45 
Generalnew (?) .NET memory usage solution Pin
User 221952029-Jan-06 17:44
User 221952029-Jan-06 17:44 
GeneralRe: new (?) .NET memory usage solution Pin
leppie29-Jan-06 18:27
leppie29-Jan-06 18:27 
GeneralRe: new (?) .NET memory usage solution Pin
User 221952029-Jan-06 18:35
User 221952029-Jan-06 18:35 
GeneralRe: new (?) .NET memory usage solution Pin
Colin Angus Mackay29-Jan-06 21:21
Colin Angus Mackay29-Jan-06 21:21 
GeneralRe: new (?) .NET memory usage solution Pin
User 221952029-Jan-06 21:55
User 221952029-Jan-06 21:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.