473,382 Members | 1,692 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,382 software developers and data experts.

Problem with strange psychic garbage collection freakout!

I have an extremely weird problem that I have no idea how to approach.
I have a simple page with a search textbox and a search button. The button
causes a postback, where I perform the search and display the results in a
DIV that has a tree. I've tested all the code up until I add in the code for
adjusting the tree in the DIV and it all works fine without problems. I can
perform the search and put the results in the body of the page and its very
fast. But when I add in my tree adjustment code, something very strange
happens.
The first time the user clicks on the search button, the OnClick event
immediately fires, I run quickly through my code, and I return the page to
the user with everything displaying how I want. The SECOND time the button
is clicked, all hell breaks loose. Watching GC stats in Performance admin
tool, % spent in GC spikes from .08% to around 70%, corresponding to Gen 0
heap size spiking like crazy (minimum value of 262k to max of 5.25m in under
5 seconds), and Gen 0,1 and 2 collections steadily ramping up from around
6000 to 7000 in about 15 seconds. Everything grinds to a halt until it
settles down. The freaky thing is that this is happening BEFORE the OnClick
event, and my code, is fired. After all the craziness calms down is when the
debugger breaks into the OnClick method. After this point, all my code runs
quickly and the page is returned to the caller.
I've gone through and commented out all of my code in the event handler,
uncommenting line by line until I find the point where this starts to happen.
I've then gone and uncommented all other code, and left this one line
commented to determine if this is what is causing the freakout. Doing this,
I definitely identified that this method call, if not commented out, causes
the GC to do its freakout. So, you would think that this one line of code is
where all the trouble is. The method I'm calling in this line is in an
object I'm doing some much more complex stuff in before and after this line.
The function is very simple:

public void ExpandTo(TreeNode node)
{
node.Expanded = true;
TreeNode parent = node.Parent;
while(parent != null)
{
parent.Expanded = true;
parent = parent.Parent;
}
}

This tree is only 5 levels deep, so the max number of loops this can execute
is four times (confirmed). That's only 4-5 TreeNode objects being created
and released, and they're not much more complex than structs.

My post boils down to two things:
1) What the hell is happening here? I'd have no question if the GC
explosion happened in my code, but it appears to happen before the OnClick
event fires. Why is the CLR freaking when that one simple function is GOING
to be called? Why not freak out WHEN its called?
2) How the heck can I troubleshoot something like this? ILDASM the DLL to
see what's going on inbetween the button click and my event handler being
fired?
Nov 19 '05 #1
4 1410
Sounds like your "tree" has a lot of HTML in it, and/or a lot of string
manipulation happening on PostBack.
What kind of "tree" are we talking about?
--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
A watched clock never boils.

"William Sullivan" <Wi*************@discussions.microsoft.com> wrote in
message news:06**********************************@microsof t.com...
I have an extremely weird problem that I have no idea how to approach.
I have a simple page with a search textbox and a search button. The
button
causes a postback, where I perform the search and display the results in a
DIV that has a tree. I've tested all the code up until I add in the code
for
adjusting the tree in the DIV and it all works fine without problems. I
can
perform the search and put the results in the body of the page and its
very
fast. But when I add in my tree adjustment code, something very strange
happens.
The first time the user clicks on the search button, the OnClick event
immediately fires, I run quickly through my code, and I return the page to
the user with everything displaying how I want. The SECOND time the
button
is clicked, all hell breaks loose. Watching GC stats in Performance admin
tool, % spent in GC spikes from .08% to around 70%, corresponding to Gen 0
heap size spiking like crazy (minimum value of 262k to max of 5.25m in
under
5 seconds), and Gen 0,1 and 2 collections steadily ramping up from around
6000 to 7000 in about 15 seconds. Everything grinds to a halt until it
settles down. The freaky thing is that this is happening BEFORE the
OnClick
event, and my code, is fired. After all the craziness calms down is when
the
debugger breaks into the OnClick method. After this point, all my code
runs
quickly and the page is returned to the caller.
I've gone through and commented out all of my code in the event handler,
uncommenting line by line until I find the point where this starts to
happen.
I've then gone and uncommented all other code, and left this one line
commented to determine if this is what is causing the freakout. Doing
this,
I definitely identified that this method call, if not commented out,
causes
the GC to do its freakout. So, you would think that this one line of code
is
where all the trouble is. The method I'm calling in this line is in an
object I'm doing some much more complex stuff in before and after this
line.
The function is very simple:

public void ExpandTo(TreeNode node)
{
node.Expanded = true;
TreeNode parent = node.Parent;
while(parent != null)
{
parent.Expanded = true;
parent = parent.Parent;
}
}

This tree is only 5 levels deep, so the max number of loops this can
execute
is four times (confirmed). That's only 4-5 TreeNode objects being created
and released, and they're not much more complex than structs.

My post boils down to two things:
1) What the hell is happening here? I'd have no question if the GC
explosion happened in my code, but it appears to happen before the OnClick
event fires. Why is the CLR freaking when that one simple function is
GOING
to be called? Why not freak out WHEN its called?
2) How the heck can I troubleshoot something like this? ILDASM the DLL
to
see what's going on inbetween the button click and my event handler being
fired?

Nov 19 '05 #2
*BUZZ* Wrong! You see the method that causes GC to skyrocket -- BEFORE it
executes -- below. The problem occurrs when the tree has five nodes in it or
five hundred. And, btw, all string manips in my program use SB's, of
course... Try again.

"Kevin Spencer" wrote:
Sounds like your "tree" has a lot of HTML in it, and/or a lot of string
manipulation happening on PostBack.
What kind of "tree" are we talking about?
--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
A watched clock never boils.

"William Sullivan" <Wi*************@discussions.microsoft.com> wrote in
message news:06**********************************@microsof t.com...
I have an extremely weird problem that I have no idea how to approach.
I have a simple page with a search textbox and a search button. The
button
causes a postback, where I perform the search and display the results in a
DIV that has a tree. I've tested all the code up until I add in the code
for
adjusting the tree in the DIV and it all works fine without problems. I
can
perform the search and put the results in the body of the page and its
very
fast. But when I add in my tree adjustment code, something very strange
happens.
The first time the user clicks on the search button, the OnClick event
immediately fires, I run quickly through my code, and I return the page to
the user with everything displaying how I want. The SECOND time the
button
is clicked, all hell breaks loose. Watching GC stats in Performance admin
tool, % spent in GC spikes from .08% to around 70%, corresponding to Gen 0
heap size spiking like crazy (minimum value of 262k to max of 5.25m in
under
5 seconds), and Gen 0,1 and 2 collections steadily ramping up from around
6000 to 7000 in about 15 seconds. Everything grinds to a halt until it
settles down. The freaky thing is that this is happening BEFORE the
OnClick
event, and my code, is fired. After all the craziness calms down is when
the
debugger breaks into the OnClick method. After this point, all my code
runs
quickly and the page is returned to the caller.
I've gone through and commented out all of my code in the event handler,
uncommenting line by line until I find the point where this starts to
happen.
I've then gone and uncommented all other code, and left this one line
commented to determine if this is what is causing the freakout. Doing
this,
I definitely identified that this method call, if not commented out,
causes
the GC to do its freakout. So, you would think that this one line of code
is
where all the trouble is. The method I'm calling in this line is in an
object I'm doing some much more complex stuff in before and after this
line.
The function is very simple:

public void ExpandTo(TreeNode node)
{
node.Expanded = true;
TreeNode parent = node.Parent;
while(parent != null)
{
parent.Expanded = true;
parent = parent.Parent;
}
}

This tree is only 5 levels deep, so the max number of loops this can
execute
is four times (confirmed). That's only 4-5 TreeNode objects being created
and released, and they're not much more complex than structs.

My post boils down to two things:
1) What the hell is happening here? I'd have no question if the GC
explosion happened in my code, but it appears to happen before the OnClick
event fires. Why is the CLR freaking when that one simple function is
GOING
to be called? Why not freak out WHEN its called?
2) How the heck can I troubleshoot something like this? ILDASM the DLL
to
see what's going on inbetween the button click and my event handler being
fired?


Nov 19 '05 #3
William Sullivan wrote:
*BUZZ* Wrong! You see the method that causes GC to skyrocket -- BEFORE it
executes -- below. The problem occurrs when the tree has five nodes in it or
five hundred. And, btw, all string manips in my program use SB's, of
course... Try again.

Hi William,

that's not a great way of winning friends or influencing people -
remember, the help you may or may not receive here is *free*.

1) Are you doing anything in the Page_Load?

2) What is the tree? Is it a set of spans you're constructing yourself,
with javascript code to open/close branches, or a third-party control,
or what?

3) My instant suspicion is ViewState - when you've done your first
click (which you say goes through pretty instantly), can you examine
the source in the browser? Is the hidden viewstate field HUGE? If so,
something may be attempting to reconstruct a lot of state before
allowing your event handler to fire. Find it and kill it.

Damien

Nov 19 '05 #4
I should have studied my trace before i posted. My tree size explodes when
searching and displaying the results of the search. The size isn't bad on
the backend, but when aspnet attempts to pack the tree into the viewstate and
then deal with it back on the server, it utterly destroys my performance.
Turning off viewstate for the tree div (which I didn't need anyhow; glad it
was on default) solved the problem.

If you're wondering, the tree is in the specs, so I can't do much about it;
I build it dynamically using ajax in order to avoid sending everything at
once.

"William Sullivan" wrote:
I have an extremely weird problem that I have no idea how to approach.
I have a simple page with a search textbox and a search button. The button
causes a postback, where I perform the search and display the results in a
DIV that has a tree. I've tested all the code up until I add in the code for
adjusting the tree in the DIV and it all works fine without problems. I can
perform the search and put the results in the body of the page and its very
fast. But when I add in my tree adjustment code, something very strange
happens.
The first time the user clicks on the search button, the OnClick event
immediately fires, I run quickly through my code, and I return the page to
the user with everything displaying how I want. The SECOND time the button
is clicked, all hell breaks loose. Watching GC stats in Performance admin
tool, % spent in GC spikes from .08% to around 70%, corresponding to Gen 0
heap size spiking like crazy (minimum value of 262k to max of 5.25m in under
5 seconds), and Gen 0,1 and 2 collections steadily ramping up from around
6000 to 7000 in about 15 seconds. Everything grinds to a halt until it
settles down. The freaky thing is that this is happening BEFORE the OnClick
event, and my code, is fired. After all the craziness calms down is when the
debugger breaks into the OnClick method. After this point, all my code runs
quickly and the page is returned to the caller.
I've gone through and commented out all of my code in the event handler,
uncommenting line by line until I find the point where this starts to happen.
I've then gone and uncommented all other code, and left this one line
commented to determine if this is what is causing the freakout. Doing this,
I definitely identified that this method call, if not commented out, causes
the GC to do its freakout. So, you would think that this one line of code is
where all the trouble is. The method I'm calling in this line is in an
object I'm doing some much more complex stuff in before and after this line.
The function is very simple:

public void ExpandTo(TreeNode node)
{
node.Expanded = true;
TreeNode parent = node.Parent;
while(parent != null)
{
parent.Expanded = true;
parent = parent.Parent;
}
}

This tree is only 5 levels deep, so the max number of loops this can execute
is four times (confirmed). That's only 4-5 TreeNode objects being created
and released, and they're not much more complex than structs.

My post boils down to two things:
1) What the hell is happening here? I'd have no question if the GC
explosion happened in my code, but it appears to happen before the OnClick
event fires. Why is the CLR freaking when that one simple function is GOING
to be called? Why not freak out WHEN its called?
2) How the heck can I troubleshoot something like this? ILDASM the DLL to
see what's going on inbetween the button click and my event handler being
fired?

Nov 19 '05 #5

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

Similar topics

0
by: Andreas Suurkuusk | last post by:
Hi, I just noticed your post in the "C# memory problem: no end for our problem?" thread. In the post you implied that I do not how the garbage collector works and that I mislead people. Since...
0
by: Refky Wahib | last post by:
Hi I need Technical Support I finished a Great project using .Net and SQL Server and .Net Mobile Control My Business case is to implement this Program to accept about 1 Million concurrent...
22
by: Marina | last post by:
Hi, Consider the following situation I have the following routine running repeatedly (curControl is a UserControl with say 1000 textboxes and a big array of strings): Public Sub...
11
by: Rick | last post by:
Hi, My question is.. if Lisp, a 40 year old language supports garbage collection, why didn't the authors of C++ choose garbage collection for this language? Are there fundamental reasons behind...
5
by: Bob lazarchik | last post by:
Hello: We are considering developing a time critical system in C#. Our tool used in Semiconductor production and we need to be able to take meaurements at precise 10.0 ms intervals( 1000...
1
by: Refky Wahib | last post by:
Hi Actually I need Technical Support I finished a Great project using .Net and SQL Server and .Net Mobile Control My Business case is to implement this Program to accept about 1 Million...
6
by: per9000 | last post by:
An interesting/annoying problem. I created a small example to provoke an exception I keep getting. Basically I have a C-struct (Container) with a function-pointer in it. I perform repeated calls...
10
by: stefven blonqhern | last post by:
hello all, having a problem with derived classes. i'll show by pseudo code example. first the base class and derived classes: class Shape { // base class for all shapes public: virtual void...
158
by: pushpakulkar | last post by:
Hi all, Is garbage collection possible in C++. It doesn't come as part of language support. Is there any specific reason for the same due to the way the language is designed. Or it is...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.