Click here to Skip to main content
14,834,806 members
Home / Discussions / C#
   

C#

 
QuestionRemote Desktop Connection Pin
singhdurgesh16-Jun-09 0:17
Membersinghdurgesh16-Jun-09 0:17 
AnswerRe: Remote Desktop Connection [modified] Pin
Baran M16-Jun-09 1:38
MemberBaran M16-Jun-09 1:38 
GeneralRe: Remote Desktop Connection Pin
singhdurgesh16-Jun-09 1:56
Membersinghdurgesh16-Jun-09 1:56 
GeneralRe: Remote Desktop Connection Pin
Baran M16-Jun-09 2:03
MemberBaran M16-Jun-09 2:03 
GeneralRe: Remote Desktop Connection Pin
singhdurgesh16-Jun-09 2:17
Membersinghdurgesh16-Jun-09 2:17 
GeneralRe: Remote Desktop Connection Pin
Baran M16-Jun-09 2:38
MemberBaran M16-Jun-09 2:38 
QuestionTracking number of a given object stored in memory Pin
Nil_IQ15-Jun-09 23:59
MemberNil_IQ15-Jun-09 23:59 
AnswerRe: Tracking number of a given object stored in memory [modified] Pin
Luc Pattyn16-Jun-09 0:22
sitebuilderLuc Pattyn16-Jun-09 0:22 
Hi,

proper use of try-catch blocks should pinpoint the problem.
I know of three ways to get an OOM Exception:

1.
the most surprising one: some methods throw OOM on bad inputs, most notoriously: Image.FromFile().

2.
you are really running out of memory; typically that means you are preventing objects from being collected. You can watch your app grow, roughly through Task Manager; more correctly by incorporating a display of Environment.WorkingSet in your app.

One way of keeping objects around is by storing references to lots of, or all, objects you create; maybe for debugging, for statistical information, as a cache, whatever. If so, consider the WeakReference class.

3.
you have objects larger than 80KB; those get allocated on the "large-object-heap", which never gets compacted, and hence could become fragmented, resulting in an OOM even when lots of free memory is still around (but each chunk is smaller than the size needed).

Remember: lots of collections (ArrayList, List< T>, etc) are stored as arrays, and such arrays get doubled in size and copied each time their capacity gets exceeded.
IMO you can't reliably design a long running .NET app if you need large objects, unless you:
- either make them all the same size;
- or perform the entire memory management for large objects yourself.
Both of which may be tedious. A third possibility is making your app restart periodically all by itself.

Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.

modified on Tuesday, June 16, 2009 6:33 AM

JokeRe: Tracking number of a given object stored in memory Pin
OriginalGriff16-Jun-09 1:14
mveOriginalGriff16-Jun-09 1:14 
GeneralRe: Tracking number of a given object stored in memory Pin
Luc Pattyn16-Jun-09 1:26
sitebuilderLuc Pattyn16-Jun-09 1:26 
AnswerRe: Tracking number of a given object stored in memory Pin
Rob Philpott16-Jun-09 0:22
MemberRob Philpott16-Jun-09 0:22 
QuestionGroup Policy Management Pin
subhabasu15-Jun-09 23:52
Membersubhabasu15-Jun-09 23:52 
AnswerRe: Group Policy Management Pin
Calla17-Jun-09 0:48
MemberCalla17-Jun-09 0:48 
GeneralRe: Group Policy Management Pin
subhabasu17-Jun-09 18:24
Membersubhabasu17-Jun-09 18:24 
QuestionSerial Ports problem Pin
izakiel15-Jun-09 23:16
Memberizakiel15-Jun-09 23:16 
AnswerRe: Serial Ports problem Pin
shineqiujuan12-Jan-10 22:26
Membershineqiujuan12-Jan-10 22:26 
QuestionC# - sending mails Pin
treuveni15-Jun-09 22:04
Membertreuveni15-Jun-09 22:04 
AnswerRe: C# - sending mails Pin
Christian Graus15-Jun-09 22:15
protectorChristian Graus15-Jun-09 22:15 
AnswerRe: C# - sending mails Pin
Luc Pattyn15-Jun-09 22:44
sitebuilderLuc Pattyn15-Jun-09 22:44 
AnswerRe: C# - sending mails Pin
Nil_IQ16-Jun-09 0:04
MemberNil_IQ16-Jun-09 0:04 
GeneralRe: C# - sending mails Pin
treuveni16-Jun-09 1:59
Membertreuveni16-Jun-09 1:59 
QuestionRead Text Pin
arkiboys15-Jun-09 21:35
Memberarkiboys15-Jun-09 21:35 
AnswerRe: Read Text Pin
himanshu256115-Jun-09 21:41
Memberhimanshu256115-Jun-09 21:41 
AnswerRe: Read Text Pin
Christian Graus15-Jun-09 22:16
protectorChristian Graus15-Jun-09 22:16 
GeneralRe: Read Text Pin
arkiboys16-Jun-09 0:35
Memberarkiboys16-Jun-09 0:35 

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.