Click here to Skip to main content
15,904,416 members
Home / Discussions / C#
   

C#

 
QuestionChange Parent form from Dialog Box Pin
bootn6-Sep-05 17:11
bootn6-Sep-05 17:11 
AnswerRe: Change Parent form from Dialog Box Pin
Christian Graus6-Sep-05 17:29
protectorChristian Graus6-Sep-05 17:29 
QuestionMemory Management Pin
VickyC#6-Sep-05 15:08
VickyC#6-Sep-05 15:08 
AnswerRe: Memory Management Pin
Matt Gerrans6-Sep-05 15:30
Matt Gerrans6-Sep-05 15:30 
GeneralRe: Memory Management Pin
VickyC#6-Sep-05 16:02
VickyC#6-Sep-05 16:02 
GeneralRe: Memory Management Pin
Dave Kreskowiak6-Sep-05 16:18
mveDave Kreskowiak6-Sep-05 16:18 
GeneralRe: Memory Management Pin
VickyC#6-Sep-05 16:33
VickyC#6-Sep-05 16:33 
GeneralRe: Memory Management Pin
Matt Gerrans6-Sep-05 20:00
Matt Gerrans6-Sep-05 20:00 
Not only that, but you'll see this same phenomenon with unmanaged apps, where you allocate memory, then free it, but Task Manager does not show you going back to the original amount. If you don't believe me, write yourself a little C++ app that allocates a few meg on the click of a button and frees it on another click and watch in Task Manager. So, it is not only the CLR that does this thing of not fully releasing dereferenced memory, but also the OS itself. That is because they both have the expecatation that an app will probably repeat its past behavior, so why waste all the extra cycles completely releasing the memory, then going to reallocate it a short time later. If that memory really is not used by the app again and other apps need it, that more complete deallocation will take place.

You can use the SetProcessWorkingSetSize() API function to hurry up and "collect" the the memory that your app has released. I had an app that would use a few meg of memory infrequently and got some complaints that it was taking up too much memory (people looking at Task Manager); I added a call to SetProcessWorkingSetSize() right before it went into its "background" mode and it showed up quite tiny in Task Manager (I forget the exact numbers, but it went from several meg, to a few K). Keep in mind though, that this is only for cosmetic purposes and doesn't really make your app use memory more efficiently or anything like that (and in fact may make your app perform worse, since when it does try to use that memory again, it will probably be slower in getting it).

Matt Gerrans
GeneralRe: Memory Management Pin
Luis Alonso Ramos6-Sep-05 16:55
Luis Alonso Ramos6-Sep-05 16:55 
AnswerRe: Memory Management Pin
Christian Graus6-Sep-05 16:56
protectorChristian Graus6-Sep-05 16:56 
GeneralRe: Memory Management Pin
VickyC#6-Sep-05 17:04
VickyC#6-Sep-05 17:04 
GeneralRe: Memory Management Pin
Christian Graus6-Sep-05 17:06
protectorChristian Graus6-Sep-05 17:06 
GeneralRe: Memory Management Pin
VickyC#6-Sep-05 17:14
VickyC#6-Sep-05 17:14 
GeneralRe: Memory Management Pin
Christian Graus6-Sep-05 17:15
protectorChristian Graus6-Sep-05 17:15 
GeneralRe: Memory Management Pin
VickyC#6-Sep-05 17:32
VickyC#6-Sep-05 17:32 
GeneralRe: Memory Management Pin
Christian Graus6-Sep-05 17:35
protectorChristian Graus6-Sep-05 17:35 
GeneralRe: Memory Management Pin
VickyC#6-Sep-05 17:39
VickyC#6-Sep-05 17:39 
GeneralRe: Memory Management Pin
Dave Kreskowiak7-Sep-05 0:56
mveDave Kreskowiak7-Sep-05 0:56 
GeneralRe: Memory Management Pin
Christian Graus7-Sep-05 12:32
protectorChristian Graus7-Sep-05 12:32 
GeneralRe: Memory Management Pin
Dave Kreskowiak7-Sep-05 16:50
mveDave Kreskowiak7-Sep-05 16:50 
GeneralRe: Memory Management Pin
VickyC#7-Sep-05 20:18
VickyC#7-Sep-05 20:18 
QuestionTreeView Problem Pin
snouto6-Sep-05 14:47
snouto6-Sep-05 14:47 
QuestionDock form to taskbar? Pin
ehollar6-Sep-05 14:43
ehollar6-Sep-05 14:43 
AnswerRe: Dock form to taskbar? Pin
Luis Alonso Ramos6-Sep-05 17:00
Luis Alonso Ramos6-Sep-05 17:00 
GeneralRe: Dock form to taskbar? Pin
ehollar7-Sep-05 5:14
ehollar7-Sep-05 5:14 

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.