Click here to Skip to main content
15,895,423 members
Home / Discussions / C#
   

C#

 
AnswerRe: Help regarding open source c# project Pin
Douglas Troy4-Apr-07 6:07
Douglas Troy4-Apr-07 6:07 
QuestionPass By Ref Pin
swjam4-Apr-07 5:14
swjam4-Apr-07 5:14 
AnswerRe: Pass By Ref Pin
Russell Jones4-Apr-07 6:04
Russell Jones4-Apr-07 6:04 
AnswerRe: Pass By Ref Pin
Vikram A Punathambekar4-Apr-07 17:39
Vikram A Punathambekar4-Apr-07 17:39 
QuestionMemory leak Pin
HexaDeveloper4-Apr-07 5:11
HexaDeveloper4-Apr-07 5:11 
AnswerRe: Memory leak Pin
Russell Jones4-Apr-07 6:06
Russell Jones4-Apr-07 6:06 
GeneralRe: Memory leak Pin
HexaDeveloper4-Apr-07 7:44
HexaDeveloper4-Apr-07 7:44 
GeneralRe: Memory leak Pin
Luc Pattyn4-Apr-07 11:06
sitebuilderLuc Pattyn4-Apr-07 11:06 
Hi,

if you create some objects (a Pen, Brush or any other instance of a class that has
a public Dispose() method) inside your OnPaint method, you MUST call Dispose for them.

Additionally, if you need the same object over and over (such as new Pen(myColor)) then
I suggest you create it only once and keep it in a class member (rather than continuously
creating and disposing and collecting them).

And finally, if the objects you need correspond to system objects (such as the ones
available in SystemPens, SystemBrushes,...) I suggest you use these (without new,
without Dispose !).

And I do not recommend you call GC.Collect at all (the gc works fine all by itself),
and certainly not from inside any OnPaint method ! (GC.Collect is expensive and
should not be called by the UI thread, it might ruin the responsiveness).

Smile | :)



Luc Pattyn

[My Articles]

GeneralRe: Memory leak Pin
HexaDeveloper8-Apr-07 5:49
HexaDeveloper8-Apr-07 5:49 
GeneralRe: Memory leak Pin
Luc Pattyn8-Apr-07 6:37
sitebuilderLuc Pattyn8-Apr-07 6:37 
GeneralRe: Memory leak Pin
HexaDeveloper8-Apr-07 6:49
HexaDeveloper8-Apr-07 6:49 
GeneralRe: Memory leak Pin
Luc Pattyn8-Apr-07 7:08
sitebuilderLuc Pattyn8-Apr-07 7:08 
GeneralRe: Memory leak Pin
HexaDeveloper8-Apr-07 7:12
HexaDeveloper8-Apr-07 7:12 
GeneralRe: Memory leak [modified] Pin
Luc Pattyn8-Apr-07 11:21
sitebuilderLuc Pattyn8-Apr-07 11:21 
GeneralRe: Memory leak Pin
HexaDeveloper8-Apr-07 12:43
HexaDeveloper8-Apr-07 12:43 
GeneralRe: Memory leak Pin
Luc Pattyn8-Apr-07 13:05
sitebuilderLuc Pattyn8-Apr-07 13:05 
QuestionGet Controls by name Pin
swjam4-Apr-07 5:03
swjam4-Apr-07 5:03 
AnswerRe: Get Controls by name Pin
B.King4-Apr-07 5:50
B.King4-Apr-07 5:50 
QuestionHow to specify an event handler Pin
peterchen4-Apr-07 5:02
peterchen4-Apr-07 5:02 
AnswerRe: How to specify an event handler Pin
mikanu4-Apr-07 6:48
mikanu4-Apr-07 6:48 
QuestionMulti-select ComboBox Pin
Amatista4-Apr-07 4:46
Amatista4-Apr-07 4:46 
AnswerRe: Multi-select ComboBox Pin
Douglas Troy4-Apr-07 6:00
Douglas Troy4-Apr-07 6:00 
GeneralRe: Multi-select ComboBox Pin
Amatista4-Apr-07 22:27
Amatista4-Apr-07 22:27 
GeneralRe: Multi-select ComboBox Pin
Douglas Troy5-Apr-07 5:34
Douglas Troy5-Apr-07 5:34 
GeneralRe: Multi-select ComboBox Pin
Amatista10-Apr-07 2:27
Amatista10-Apr-07 2:27 

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.