Click here to Skip to main content
15,905,028 members
Home / Discussions / C#
   

C#

 
QuestionProblem with while loop and text file Pin
kallileo16-Jun-09 0:56
kallileo16-Jun-09 0:56 
AnswerRe: Problem with while loop and text file [modified] Pin
Luc Pattyn16-Jun-09 1:03
sitebuilderLuc Pattyn16-Jun-09 1:03 
GeneralRe: Problem with while loop and text file Pin
OriginalGriff16-Jun-09 1:11
mveOriginalGriff16-Jun-09 1:11 
GeneralRe: Problem with while loop and text file Pin
Le centriste16-Jun-09 2:18
Le centriste16-Jun-09 2:18 
GeneralRe: Problem with while loop and text file Pin
Luc Pattyn16-Jun-09 2:42
sitebuilderLuc Pattyn16-Jun-09 2:42 
GeneralRe: Problem with while loop and text file Pin
kallileo16-Jun-09 2:46
kallileo16-Jun-09 2:46 
QuestionMultiple user accessing single DB Pin
Hum Dum16-Jun-09 0:50
Hum Dum16-Jun-09 0:50 
AnswerRe: Multiple user accessing single DB Pin
Tom Deketelaere16-Jun-09 1:22
professionalTom Deketelaere16-Jun-09 1:22 
GeneralRe: Multiple user accessing single DB Pin
Hum Dum16-Jun-09 18:55
Hum Dum16-Jun-09 18:55 
GeneralRe: Multiple user accessing single DB Pin
Tom Deketelaere16-Jun-09 21:09
professionalTom Deketelaere16-Jun-09 21:09 
AnswerRe: Multiple user accessing single DB Pin
Nagy Vilmos16-Jun-09 2:35
professionalNagy Vilmos16-Jun-09 2:35 
GeneralRe: Multiple user accessing single DB Pin
Hum Dum16-Jun-09 18:58
Hum Dum16-Jun-09 18:58 
AnswerRe: Multiple user accessing single DB Pin
OriginalGriff16-Jun-09 4:40
mveOriginalGriff16-Jun-09 4:40 
Questioncontroling cells in TableLayoutPanel Pin
samy10016-Jun-09 0:43
samy10016-Jun-09 0:43 
AnswerRe: controling cells in TableLayoutPanel Pin
OriginalGriff16-Jun-09 1:05
mveOriginalGriff16-Jun-09 1:05 
QuestionRemote Desktop Connection Pin
singhdurgesh16-Jun-09 0:17
singhdurgesh16-Jun-09 0:17 
AnswerRe: Remote Desktop Connection [modified] Pin
Baran M16-Jun-09 1:38
Baran M16-Jun-09 1:38 
GeneralRe: Remote Desktop Connection Pin
singhdurgesh16-Jun-09 1:56
singhdurgesh16-Jun-09 1:56 
GeneralRe: Remote Desktop Connection Pin
Baran M16-Jun-09 2:03
Baran M16-Jun-09 2:03 
GeneralRe: Remote Desktop Connection Pin
singhdurgesh16-Jun-09 2:17
singhdurgesh16-Jun-09 2:17 
GeneralRe: Remote Desktop Connection Pin
Baran M16-Jun-09 2:38
Baran M16-Jun-09 2:38 
QuestionTracking number of a given object stored in memory Pin
Nil_IQ15-Jun-09 23:59
Nil_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 

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.