473,396 Members | 1,599 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Confused about memory usage.

I have an application (windows service) that in the beginning reads data
rapidly into a collection of large object trees. Each object tree in
the collection is about 100mb and typically there are 6-20 object trees
in the collection. When the application starts and the data is being
read in, I watch the memory generations via the Process Explorer
(basically .NET CLR Memory perf counters). What I see is a bit
confusing. Most of the memory gets promoted from Gen0 to Gen2 to Gen2
(and to the Large Object Heap) in a fairly fast succession. When all
the database information has been read in, the memory usage settles in
the following numbers.

Gen0 1,048,576
Gen1 67,044
Gen2 571,410,644
LOH 71,653,000

Then after about 10 minutes of that I attempt to dump the memory by
setting all the root object to null, followed by GC.Collect() and
GC.WaitForPendingFinalizers().

foreach obj in collection
{
obj.Dispose();
obj = null;

print ("Before " + GC.GetTotalMemory(false).ToString());
GC.Collect();
GC.WaitForPendingFinalizers();
print ("After " + GC.GetTotalMemory(true).ToString());
}

The root objects are collected, this I know, because the finalizers
write stuff to the log. Now the memory looks like this:

Gen0 1,048,576
Gen1 2,940
Gen2 518,267,836
LOH 71,556,328

So basically, Gen2 decreased a bit, while none of the other Generations
changed much.

In addition, I check the memory usage via GC.GetTotalMemory method.
Before the first object is collected, it reports memory usage at
506,804,036. With every GC.Collect()/GC.WaitForPendingFinalizers()
call, the value decreases by about 5-10mb. After the final GC is
forced, the memory is reported at 435,156,904. I am not sure where this
number comes from, but it does not jive with what is being shown from
perfmon.

So I have a couple of questions here:

1. Given that my root node gets collected, why does the memory usage
not decrease.

2. Where does GC.GetTotalMemory get its numbers from and why do they
not match with what's in the heap.

3. Where do I go from here as far as debugging the memory leak (other
than SOS)?

Regards
May 30 '07 #1
1 1846
Never mind. One call to MS Support and a lesson in WinDbg/SOS debugging
techniques located my bug.

Frank Rizzo wrote:
I have an application (windows service) that in the beginning reads data
rapidly into a collection of large object trees. Each object tree in
the collection is about 100mb and typically there are 6-20 object trees
in the collection. When the application starts and the data is being
read in, I watch the memory generations via the Process Explorer
(basically .NET CLR Memory perf counters). What I see is a bit
confusing. Most of the memory gets promoted from Gen0 to Gen2 to Gen2
(and to the Large Object Heap) in a fairly fast succession. When all
the database information has been read in, the memory usage settles in
the following numbers.

Gen0 1,048,576
Gen1 67,044
Gen2 571,410,644
LOH 71,653,000

Then after about 10 minutes of that I attempt to dump the memory by
setting all the root object to null, followed by GC.Collect() and
GC.WaitForPendingFinalizers().

foreach obj in collection
{
obj.Dispose();
obj = null;

print ("Before " + GC.GetTotalMemory(false).ToString());
GC.Collect();
GC.WaitForPendingFinalizers();
print ("After " + GC.GetTotalMemory(true).ToString());
}

The root objects are collected, this I know, because the finalizers
write stuff to the log. Now the memory looks like this:

Gen0 1,048,576
Gen1 2,940
Gen2 518,267,836
LOH 71,556,328

So basically, Gen2 decreased a bit, while none of the other Generations
changed much.

In addition, I check the memory usage via GC.GetTotalMemory method.
Before the first object is collected, it reports memory usage at
506,804,036. With every GC.Collect()/GC.WaitForPendingFinalizers()
call, the value decreases by about 5-10mb. After the final GC is
forced, the memory is reported at 435,156,904. I am not sure where this
number comes from, but it does not jive with what is being shown from
perfmon.

So I have a couple of questions here:

1. Given that my root node gets collected, why does the memory usage
not decrease.

2. Where does GC.GetTotalMemory get its numbers from and why do they
not match with what's in the heap.

3. Where do I go from here as far as debugging the memory leak (other
than SOS)?

Regards
May 31 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

29
by: Alexander Mahr | last post by:
Dear Newsgroup, I'm somehow confused with the usage of the static keyword. I can see two function of the keyword static in conjunction with a data member of a class. 1. The data member...
5
by: Justice | last post by:
Currently I'm doing some experimenting with the XMLHTTP object in Javascript. Now, the XMLHttp object is asynchronous (at least in this case), and the following code causes a significant memory...
2
by: tomvr | last post by:
Hello I have noticed some 'weird' memory usage in a vb.net windows app The situation is as follows I have an app (heavy on images) with 2 forms (actually there are more forms and on starting...
6
by: Tom | last post by:
We have a VERY simple .NET C# Form Application, that has about a 23MB Memory Footprint. It starts a window runs a process and does a regular expression. I have done a GC.Collect to make sure that,...
2
by: Jarvis | last post by:
I've made a testing program to test the memory usage of some Data Forms. I create a MDI parent form with one single MDI child form, which is a Data Form generated by .NET Data Form Wizard. To...
3
by: Ian Taite | last post by:
Hello, I'm exploring why one of my C# .NET apps has "high" memory usage, and whether I can reduce the memory usage. I have an app that wakes up and processes text files into a database...
13
by: Richard | last post by:
vector<char*> m_Text; m_Text.resize(1); char* foo = "FOO"; char* bar = "BAR"; char* foobar = (char*)malloc(strlen(foo) + strlen(bar) + 1); if (foobar) { strcpy(foobar, foo); strcat(foobar,...
20
by: Philip Carnstam | last post by:
How come .Net applications use so much memory? Every application I compile uses at least 10 MB of memory, even the ones consisting of only a form and nothing else. If I minimize them though the...
1
by: Jean-Paul Calderone | last post by:
On Tue, 22 Apr 2008 14:54:37 -0700 (PDT), yzghan@gmail.com wrote: The test doesn't demonstrate any leaks. It does demonstrate that memory usage can remain at or near peak memory usage even after...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.