Click here to Skip to main content
15,887,683 members
Home / Discussions / C#
   

C#

 
JokeRe: c# function for Image Compression Pin
musefan14-Jul-09 1:19
musefan14-Jul-09 1:19 
GeneralRe: c# function for Image Compression Pin
Luc Pattyn14-Jul-09 1:42
sitebuilderLuc Pattyn14-Jul-09 1:42 
GeneralRe: c# function for Image Compression Pin
musefan14-Jul-09 2:42
musefan14-Jul-09 2:42 
GeneralRe: c# function for Image Compression Pin
Luc Pattyn14-Jul-09 2:44
sitebuilderLuc Pattyn14-Jul-09 2:44 
AnswerRe: c# function for Image Compression Pin
benjymous14-Jul-09 1:42
benjymous14-Jul-09 1:42 
AnswerRe: c# function for Image Compression Pin
Ennis Ray Lynch, Jr.14-Jul-09 6:15
Ennis Ray Lynch, Jr.14-Jul-09 6:15 
QuestionWindow Service memory leak Pin
himanshu256114-Jul-09 0:36
himanshu256114-Jul-09 0:36 
AnswerRe: Window Service memory leak Pin
Luc Pattyn14-Jul-09 1:11
sitebuilderLuc Pattyn14-Jul-09 1:11 
Hi,

there are many possible causes. Here is one most people aren't aware of:

objects larger than 80KB get allocated on the "large-object-heap", which never gets compacted. The net result is it may fragment after some time, resulting in lots of memory being free yet the heap being unable to offer a chunk of memory large enough to satisfy the latest request.

Here are some candidates for large objects:
- images
- arrays in general
- large strings (TextBox/RichTextBox often is a culprit, as it requires the concatenation of all its text)
- StringBuillders and all kinds of collections since these typically are implemented as arrays as well; such objects get an initial capacity, and when insufficient, their array gets reallocated with twice the size.

Solution: there isn't a perfect solution. Some suggestions:
- avoid large objects as much as possible, don't use (Rich)TextBox for texts exceeding a few hundred lines
- when a StringBuilder or collection will grow large, allocate it with sufficient size right away.
- periodically restart your app (once a month, once a day, depending on how active its object allocation is)

BTW: I know of no readymade way to measure fragmentation; it is easy to measure it in a disruptive way though (I think I'll write a little article on that subject).

Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.

modified on Tuesday, July 14, 2009 7:19 AM

GeneralRe: Window Service memory leak Pin
himanshu256114-Jul-09 19:40
himanshu256114-Jul-09 19:40 
GeneralRe: Window Service memory leak Pin
Luc Pattyn15-Jul-09 0:12
sitebuilderLuc Pattyn15-Jul-09 0:12 
GeneralRe: Window Service memory leak Pin
himanshu256115-Jul-09 1:38
himanshu256115-Jul-09 1:38 
GeneralRe: Window Service memory leak Pin
Luc Pattyn15-Jul-09 1:50
sitebuilderLuc Pattyn15-Jul-09 1:50 
AnswerRe: Window Service memory leak Pin
PIEBALDconsult14-Jul-09 6:24
mvePIEBALDconsult14-Jul-09 6:24 
GeneralRe: Window Service memory leak Pin
himanshu256114-Jul-09 19:42
himanshu256114-Jul-09 19:42 
Questionhorizontal scroll bar on the panel.... Pin
spalanivel14-Jul-09 0:06
spalanivel14-Jul-09 0:06 
AnswerRe: horizontal scroll bar on the panel.... Pin
Henry Minute14-Jul-09 0:26
Henry Minute14-Jul-09 0:26 
GeneralRe: horizontal scroll bar on the panel.... Pin
spalanivel14-Jul-09 0:35
spalanivel14-Jul-09 0:35 
GeneralRe: horizontal scroll bar on the panel.... Pin
Henry Minute14-Jul-09 0:43
Henry Minute14-Jul-09 0:43 
QuestionMicrosoft Visual C++ Library Pin
GauravKP13-Jul-09 23:35
professionalGauravKP13-Jul-09 23:35 
AnswerRe: Microsoft Visual C++ Library Pin
stancrm13-Jul-09 23:40
stancrm13-Jul-09 23:40 
AnswerRe: Microsoft Visual C++ Library Pin
Manas Bhardwaj13-Jul-09 23:43
professionalManas Bhardwaj13-Jul-09 23:43 
QuestionUploading Files to HTTPS site [modified] Pin
The_Collector13-Jul-09 23:28
The_Collector13-Jul-09 23:28 
AnswerRe: Uploading Files to HTTPS site Pin
Manas Bhardwaj13-Jul-09 23:39
professionalManas Bhardwaj13-Jul-09 23:39 
GeneralRe: Uploading Files to HTTPS site Pin
The_Collector14-Jul-09 2:16
The_Collector14-Jul-09 2:16 
GeneralRe: Uploading Files to HTTPS site Pin
The_Collector14-Jul-09 18:06
The_Collector14-Jul-09 18:06 

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.