I have a very small application designed so that the main thread spawns
3 additional threads. All 4 threads then wait for an event from an
Oracle database (message posted on an AQ queue), and are blocked most of
the time. The main thread may be blocked for weeks or months. The 3
spawned threads are much more active, with data to process, objects
created and freed, hourly or more often.
I've found that the application displays symptoms of a memory leak,
accumulating memory without ever releasing it. However, I can expire
the 3 spawned threads through the main thread, and when I do, memory is
immediately garbage collected.
My question is: when is the Java garbage collector invoked, and on which
thread? I've found tons of documentation on what the GC does, but so
far nothing on when it runs. My guess is, based on observing this
application, that the GC runs as part of the main thread, and that if
the main thread is blocked, GC will not occur. However, my boss refuses
to accept this explanation, but I'm sure he'd believe any one of the
subscribers to this forum.
Any suggestions would be greatly appreciated.
David Jenkins 5 2733
GC runs in a seperate thread, and in sme implementations there are more than
one thread.
here is an artcile on GC.. http://java.sun.com/docs/hotspot/gc/
"David Jenkins" <dj********@ade lphia.net> wrote in message
news:KI******** ************@ad elphia.com... I have a very small application designed so that the main thread spawns 3 additional threads. All 4 threads then wait for an event from an Oracle database (message posted on an AQ queue), and are blocked most of the time. The main thread may be blocked for weeks or months. The 3 spawned threads are much more active, with data to process, objects created and freed, hourly or more often.
I've found that the application displays symptoms of a memory leak, accumulating memory without ever releasing it. However, I can expire the 3 spawned threads through the main thread, and when I do, memory is immediately garbage collected.
My question is: when is the Java garbage collector invoked, and on which thread? I've found tons of documentation on what the GC does, but so far nothing on when it runs. My guess is, based on observing this application, that the GC runs as part of the main thread, and that if the main thread is blocked, GC will not occur. However, my boss refuses to accept this explanation, but I'm sure he'd believe any one of the subscribers to this forum.
Any suggestions would be greatly appreciated.
David Jenkins
Harish wrote: GC runs in a seperate thread, and in sme implementations there are more than one thread. here is an artcile on GC..http://java.sun.com/docs/hotspot/gc/
"David Jenkins" <dj********@ade lphia.net> wrote in message news:KI******** ************@ad elphia.com...
Thanks, this helps. I'll have to read it more carefully, but I'm still
wondering: if the GC runs on a separate thread, how does this thread
know when to perform GC? Is it perhaps event-driven, invoked whenever
an object is released? Or when one of the object spaces fills? In
either case, how is it signaled? Sorry to belabor the issue, I just
haven't found any document that describes this part of the process.
not sure about the excat way it is done. but this is how i would see it:
the GC thread(s) gets signaled by the JVM. it doesnot get invoked for every
object release.
its not preiodical either. GC AFAIK is done on a demand basis.
The thread(s) is signaled using synhronized objects.(using Object.notify)
And I guess its triggered when one of the memory space gets full.
"David Jenkins" <dj********@ade lphia.net> wrote in message
news:fs******** ************@ad elphia.com... Harish wrote: GC runs in a seperate thread, and in sme implementations there are more than one thread. here is an artcile on GC..http://java.sun.com/docs/hotspot/gc/
"David Jenkins" <dj********@ade lphia.net> wrote in message news:KI******** ************@ad elphia.com... Thanks, this helps. I'll have to read it more carefully, but I'm still wondering: if the GC runs on a separate thread, how does this thread know when to perform GC? Is it perhaps event-driven, invoked whenever an object is released? Or when one of the object spaces fills? In either case, how is it signaled? Sorry to belabor the issue, I just haven't found any document that describes this part of the process.
"Many garbage collection algorithms suspend all threads before they
run. This ensures that when the garbage collector runs, it has
complete access to the memory in the heap and can perform its tasks
safely without the threat of being preempted by another thread. When
the garbage collector is done with its work, all threads that it
suspended are resumed."
page 23 "Practical Java" Peter Haggar 2000
I'm wondering if the blocked main thread (or one or all three of its
child threads) cannot be suspended by the GC for some reason while its
three child threads are active?
--
Regards,
Casey
Casey Hawthorne wrote: "Many garbage collection algorithms suspend all threads before they run. This ensures that when the garbage collector runs, it has complete access to the memory in the heap and can perform its tasks safely without the threat of being preempted by another thread. When the garbage collector is done with its work, all threads that it suspended are resumed." page 23 "Practical Java" Peter Haggar 2000
I'm wondering if the blocked main thread (or one or all three of its child threads) cannot be suspended by the GC for some reason while its three child threads are active?
-- Regards, Casey
Knowing little of what your app does, my comments may not help.
Java GC is great, but you can defeat the GC, and have memory leaks in
Java. If you are using some Collection class to contain your objects
and then passing references to other classes that have Collections too,
your objects may may still have valid references, and will not be
garbage collected.
joseph This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Charles Jamieson |
last post by:
I declare a class
class myClass{
public:
~myClass();
|
by: Tony Johansson |
last post by:
Hello!
When you allocate object dynamically which mean on the heap I find that a
problem when using exception.
What is the prefer method to handle this kind of problem.
//Tony
|
by: JQA Academia |
last post by:
I've reinstalled twice now... I've got the Visual Studio.net Academic version 2003. During installation, I get no errors but when I try to open a new project from the inital start page, it just hangs and then eventually the application stops responding. I'm running on Windows XP Professional, I've made sure IIS is activated.
Any Ideas?
|
by: Artur |
last post by:
After trying to solve this, I noticed another strange thing. When in
secure connection Page_Load method of page is not invoked (Load event
not fired). I looked where this method is assigned to this event, it's
in On_Init method. Tested, this method is not invoked too. This happens
only in when in SSL. Can anyone help me?
Thanks.
Artur
|
by: bkunjitam |
last post by:
I am invoking a cygwin session by the following code
from win32com.client import *
a = Dispatch("Wscript.Shell")
a.Run("C:/cygwin/cygwin.bat");
a.SendKeys ("cd D:/temp/code" + "{Enter}")
| |
by: johkar |
last post by:
I need some browser implementation clarification.
In the below example, the alternate stylesheet could be invoked by
user agents that support alternate stylesheets or by script. Are
there any browsers that don't recognize "alternate stylesheet" as a
value of the rel attribute and just implement it automatically thus
overriding sheet2.css? Just need to know what I need to worry about.
<link href="sheet1.css" rel="stylesheet"...
|
by: O.B. |
last post by:
Using a TCP socket with a buffer of 6MB, I have an asynchronous
callback that is invoked from within BeginReceive. Unfortunately, the
asynchronous callback is only invoked once the receive buffer is
full. Is there a flag available that I can set such that the
asynchronous callback is invoked as soon as data is received?
|
by: Gabriel Genellina |
last post by:
En Mon, 05 May 2008 00:31:45 -0300, Barclay, Ken <Ken.Barclay@schwab.comescribió:
No entry in the error log, on the web server? (Apache?)
Perhaps you're hitting some internal limit of the cgi process, either memory or cpu time per request or temp file size...
Are you sure the script runs to completion? Output a message at the end, to be sure.
--
Gabriel Genellina
|
by: Nick |
last post by:
Hi there,
Is it possible to tell how a WebMethod was invoked? For example I would
like to determin if it was invoked via SOAP or HTTP Post. Other than
creating 2 methods I am no sure if I can do this.
Many thanks for your time.
Nick.
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |