By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,977 Members | 1,589 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,977 IT Pros & Developers. It's quick & easy.

Memory Managment and Garbage Collection

P: n/a
I've been noticing that all of my .NET apps seem to progressivly use more
and more memory. Even after several reworks of the code I can only manage
to slow the growth. Is there some Garbage Collection caveat that's holding
old data into higher generations accidentlly? Has anyone else noticed this?
Nov 15 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
An app that I'm working on literally went from 4mb of ram usage (using
process manager to view it) to 22mb of ram to run by adding two new
forms. As I've been running my apps I've noticed a larger memory usage
although I can't quite pin down what causes it.
Casey Leamon wrote:
I've been noticing that all of my .NET apps seem to progressivly use more
and more memory. Even after several reworks of the code I can only manage
to slow the growth. Is there some Garbage Collection caveat that's holding
old data into higher generations accidentlly? Has anyone else noticed this?

Nov 15 '05 #2

P: n/a
I was following this kind of thread for months and months.

Nobody could give a coerent answer.

I did a medium App and it takes between 60 and 120MB when is running. I
cannot think what the heck is taking all the memory.

..Net consume ALL THE MEMORY THAT IT CAN, I read A LOT about the garbage
collector, and if windows has memory free not used by anybody, then the
framework is going to take it, when the garbage collector "think" is time to
clean up, he will do it.

If another app require memory, the GC is going to free it.

My entire conclusion when to that path.

I love .Net environment (C#). I think is the best language ever. But the
memory management SUCKS, I bought 3 profilers, and it still it produce
memory leaks, with the events references specially, I think still is a young
environment and need more tools.

Conclusion, Right now you will come crazy to know what the hell is doing
with the memory and none tool is going to tell you who is using it.

My profilers show 8 MB taken, and the Task Manager is almost 96MB, so.......
I'm still wondering if somebody knows how to open the REAL memory taken to
see what is inside. (Some .Net Guru outside???)

Regards,

Gustavo
"Greg Merideth" <gm*******@removethis.uclabs.com> wrote in message
news:K_********************@comcast.com...
An app that I'm working on literally went from 4mb of ram usage (using
process manager to view it) to 22mb of ram to run by adding two new
forms. As I've been running my apps I've noticed a larger memory usage
although I can't quite pin down what causes it.
Casey Leamon wrote:
I've been noticing that all of my .NET apps seem to progressivly use more and more memory. Even after several reworks of the code I can only manage to slow the growth. Is there some Garbage Collection caveat that's holding old data into higher generations accidentlly? Has anyone else noticed this?

Nov 15 '05 #3

P: n/a
This only proves you should learn how to use your tools, if a profiler shows
8MB managed memory consumption, but the task manager shows 96 MB, it means
that most memory is non managed (code and data), and therefore cannot be
collected by the GC.
Another point is that most people use Taskmanager to look at memory counters
while they should use Perfmon to watch managed/unmanaged memory count, you
should know exactly what counters to look at and have some good knowledge of
the internal workings of the OS memory manager and the GC (and NO the GC is
not a memory manager its a users heap manager).

Willy.

"Gustavo Franco" <gu************@hotmail.com> wrote in message
news:uz*************@tk2msftngp13.phx.gbl...
I was following this kind of thread for months and months.

Nobody could give a coerent answer.

I did a medium App and it takes between 60 and 120MB when is running. I
cannot think what the heck is taking all the memory.

.Net consume ALL THE MEMORY THAT IT CAN, I read A LOT about the garbage
collector, and if windows has memory free not used by anybody, then the
framework is going to take it, when the garbage collector "think" is time to clean up, he will do it.

If another app require memory, the GC is going to free it.

My entire conclusion when to that path.

I love .Net environment (C#). I think is the best language ever. But the
memory management SUCKS, I bought 3 profilers, and it still it produce
memory leaks, with the events references specially, I think still is a young environment and need more tools.

Conclusion, Right now you will come crazy to know what the hell is doing
with the memory and none tool is going to tell you who is using it.

My profilers show 8 MB taken, and the Task Manager is almost 96MB, so....... I'm still wondering if somebody knows how to open the REAL memory taken to
see what is inside. (Some .Net Guru outside???)

Regards,

Gustavo
"Greg Merideth" <gm*******@removethis.uclabs.com> wrote in message
news:K_********************@comcast.com...
An app that I'm working on literally went from 4mb of ram usage (using
process manager to view it) to 22mb of ram to run by adding two new
forms. As I've been running my apps I've noticed a larger memory usage
although I can't quite pin down what causes it.
Casey Leamon wrote:
I've been noticing that all of my .NET apps seem to progressivly use more and more memory. Even after several reworks of the code I can only manage to slow the growth. Is there some Garbage Collection caveat that's holding old data into higher generations accidentlly? Has anyone else noticed this?


Nov 15 '05 #4

P: n/a
There's a lot of good information on GC in .NET on newsgroups already, if
you want to search groups.google.com for GC, WorkingSet Forms etc. where
folks more knowledgeable than I have explained it at length.

For an app that shrinks it's working set regularly, see my "self-shrinking
working set" sample here:
http://blogs.geekdojo.net/richard/posts/338.aspx

Richard

--
C#, .NET and Complex Adaptive Systems:
http://blogs.geekdojo.net/Richard
"Casey Leamon" <Pr************@007design.com> wrote in message
news:e4**************@tk2msftngp13.phx.gbl...
I've been noticing that all of my .NET apps seem to progressivly use more and more memory. Even after several reworks of the code I can only manage
to slow the growth. Is there some Garbage Collection caveat that's holding old data into higher generations accidentlly? Has anyone else noticed this?

Nov 15 '05 #5

P: n/a
Richard,

While there is nothing wrong with the sample, this is something you should
consider whit care, it's not up to a user process to take over the task of
the memory manager.
The OS (WS manager) knows exactly when/what pages should be removed from the
processes WS when it sees fit.
When tuning the WS of a running (active) process when there is enough free
memory is available, you will only:
- induce IO overhead as you move pages to the paging file (IO) and
- induce (initially unnecessary) page faults and associated IO when
reloading the needed pages.
When the OS trims working sets it will try to remove non active pages from
ALL process first until enough free pages are available to honor the memory
request.

Willy.

"Richard A. Lowe" <ch*****@yumspamyumYahoo.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
There's a lot of good information on GC in .NET on newsgroups already, if
you want to search groups.google.com for GC, WorkingSet Forms etc. where
folks more knowledgeable than I have explained it at length.

For an app that shrinks it's working set regularly, see my "self-shrinking
working set" sample here:
http://blogs.geekdojo.net/richard/posts/338.aspx

Richard

--
C#, .NET and Complex Adaptive Systems:
http://blogs.geekdojo.net/Richard
"Casey Leamon" <Pr************@007design.com> wrote in message
news:e4**************@tk2msftngp13.phx.gbl...
I've been noticing that all of my .NET apps seem to progressivly use

more
and more memory. Even after several reworks of the code I can only manage to slow the growth. Is there some Garbage Collection caveat that's

holding
old data into higher generations accidentlly? Has anyone else noticed

this?


Nov 15 '05 #6

P: n/a
I agree with you, definately. I should probably put a strong warning on
that sample (in fact I think I will!); I wrote it after reading a bunch of
"my client thinks .NET is a hog because my WinForm app takes up so much
memory" posts - since people are probably going to call the GC class
directly at any rate. There's no doubt that it *should* be left up to the
OS.

Thanks,
Richard

--
C#, .NET and Complex Adaptive Systems:
http://blogs.geekdojo.net/Richard
"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:um**************@TK2MSFTNGP11.phx.gbl...
Richard,

While there is nothing wrong with the sample, this is something you should
consider whit care, it's not up to a user process to take over the task of
the memory manager.
The OS (WS manager) knows exactly when/what pages should be removed from the processes WS when it sees fit.
When tuning the WS of a running (active) process when there is enough free
memory is available, you will only:
- induce IO overhead as you move pages to the paging file (IO) and
- induce (initially unnecessary) page faults and associated IO when
reloading the needed pages.
When the OS trims working sets it will try to remove non active pages from
ALL process first until enough free pages are available to honor the memory request.

Willy.

"Richard A. Lowe" <ch*****@yumspamyumYahoo.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
There's a lot of good information on GC in .NET on newsgroups already, if
you want to search groups.google.com for GC, WorkingSet Forms etc. where
folks more knowledgeable than I have explained it at length.

For an app that shrinks it's working set regularly, see my "self-shrinking working set" sample here:
http://blogs.geekdojo.net/richard/posts/338.aspx

Richard

--
C#, .NET and Complex Adaptive Systems:
http://blogs.geekdojo.net/Richard
"Casey Leamon" <Pr************@007design.com> wrote in message
news:e4**************@tk2msftngp13.phx.gbl...
I've been noticing that all of my .NET apps seem to progressivly use

more
and more memory. Even after several reworks of the code I can only

manage to slow the growth. Is there some Garbage Collection caveat that's

holding
old data into higher generations accidentlly? Has anyone else noticed

this?



Nov 15 '05 #7

P: n/a

"Richard A. Lowe" <ch*****@yumspamyumYahoo.com> wrote in message
news:OJ*************@tk2msftngp13.phx.gbl...
I agree with you, definately. I should probably put a strong warning on
that sample (in fact I think I will!);


Great idea.
Whats great when using such samples, is that you show how things work, but
also that you can warn for the side effects and show how to perform things
like page IO and page fault accounting, which is much MORE important than
trying to trim working sets when there is no need for it.

Willy.
Nov 15 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.