473,405 Members | 2,187 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,405 software developers and data experts.

Garbage collection - able to force it?

dd
I have a situation where the browser memory goes up and up
as each Ajax call causes new content to be deployed into a
DIV. I'd like to know if I can force garbage collection to occur.

More detail:

My code is loaded in an iframe which is in a div. The parent
page looks like this (my code is in firstiframe.html):

<div id="main div">
some content that will get replaced via Ajax calls
</div>
<div id="abc">
<iframe src="firstiframe.html" bla bla>
</div>

What the parent page does is, each time the user clicks on
some menu that causes some Ajax function to load new
content into the "main div" (e.g. a webmail page and the
user clicks on an email to open it), then the parent page
loads the new content into that main div, and at the same
time, it loads a different iframe into the innerHTML of that
div "abc".

My job, in the code in the iframe, is to dynamically insert
things into the parent page. All those things I insert into
the parent page though, must be inside the "abc" div. What
I do is, get a handle to the iframe (e.g. parent.frames[0], or
parent.getElementsByTagName('iframe').item(myifram e))
and then I insertAdjacentElement("afterEnd",newelement).

So all divs and script elements I add, are encapsulated
within div "abc" and are therefore manageable by the
parent page. What it does is, when it's doing it's Ajax
pseudo-navigation, and just prior to loading a new iframe
into "abc", is to loop through the child nodes of "abc" and
remove all the elements. It's effectively nuking everything
I added. I don't have any control over how it's doing that,
it's nothing to do with me. It appears to work though.

The problem I've noticed though, is that memory just goes
up and up and up each time one of these pseudo navigations
occurs, leading me to think that although the nodes are
being removed, they're somehow hanging on. Perhaps it's an
issue with closures persisting, or setTimeout or setInterval
having a refcount on a function, or the ActiveX controls that
were on some of the DIV's that I inserted are still running.

If I could influence garbage collection (even if just manually
from the address bar as a test) then I could see if that helps.

I'm fairly limited in what I am able to do, but I do get to give
feedback to the authors of the code that "nukes" the "abc"
div contents and can advise them that it might be their fault
that memory is increasing. I'm not sure of this though, it
could easily be my fault.

I've thought about doing a test where I keep going and going
and seeing if the browser does eventually manage it's garbage
but haven't done that yet.

Feb 1 '07 #1
1 6468
dd
I also meant to add this question to the initial post:

Can anyone think of a better way of detecting that
one of these pseudo navigations has occurred? The
onunload event in my iframe is not firing properly. I
guess the browser (IE at least anyway) only fires the
event when either a full browser navigation occurs, or
the user closes the browser, or the iframe is navigated
to somewhere else. When the iframe element simply
gets nuked (removed from the DOM) it seems that the
event doesn't occur. What I've tried doing to workaround
this, is to have some code running on a setInterval and
checking for the existence of one of the child divs that I
created inside "abc". If it detects that this child div no
longer exists, it calls my onunload handler and cancels
the setInterval.

Feb 1 '07 #2

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

Similar topics

6
by: Ganesh | last post by:
Is there a utility by microsoft (or anyone) to force garbage collection in a process without have access to the process code. regards Ganesh
2
by: Oculus | last post by:
Before I get into the question -- I know .NET isn't the right solution for this app but it's part of my clients requirements and writing this in C++ isn't an option. That being said -- my app is a...
2
by: Jenny K | last post by:
Hi everyone, I've got a console application that grabs data into 3 datatables asynchronously, and writes each datatable's data to a textfile. The problem is that the data returned by each sproc...
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...
8
by: mike2036 | last post by:
For some reason it appears that garbage collection is releasing an object that I'm still using. The object is declared in a module and instantiated within a class that is in turn instantiated by...
18
by: Larry Herbinaux | last post by:
I'm having issues with garbage collection with my long-standing service process. If you could review and point me in the right direction it would be of great help. If there are any helpful...
0
by: adubra | last post by:
Hi there, I am using a device context (DC) and a buffer to successfully draw to screen. However, when I update the DC at very high frame rate and drag the frame containing the image very quickly...
2
by: roger.dunham | last post by:
I am trying to identify whether a .NET 1.1 application that I have written has a memory leak. I thought I understood how .NET memory management worked, but it appears that there is more to it...
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...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.