Performance tuning - Object Creation

C

coltrane

I am trying to implement and run the ObjectCreation monitoring app
defined in the beginning of the Java Performance Tuning book. I have
created the monitoring code and the test app. I have also created a jar
with a modified Object class. When I try to run the test I get during
the initialization of the VM.

This is the command line and the error output:

java
-Xbootclasspath/p:.\ObjectHack.jar;\opt\java\j2sdk1.4.2_12/jre/lib/rt.jar
com.jprok.performancetuning.ObjectCreationMonitoring -t
com.jprok.performancetuning.ProfileTest

Error occurred during initialization of VM
java.lang.StackOverflowError

If I remove the HackObject.jar from the bootclasspath setting the test
app runs with out the monitoring which is what should happen.
The text does include the jar i18n.jar but I do not have that jar
installed on my system. I have java 1.4 j2se.

I added the following to the new java.lang.Object class:
(*note my package is com.jprok.performancetuning)

public Object(){
this(true);

if(com.jprok.performancetuning.ObjectCreationMonitoringFlag.monitoring)

com.jprok.performancetuning.ObjectCreationMonitoring.monitor(this);
}

public Object(boolean b)
{
}


thanks for your help with this

john
 
R

Robert Klemme

This is the command line and the error output:

java
-Xbootclasspath/p:.\ObjectHack.jar;\opt\java\j2sdk1.4.2_12/jre/lib/rt.jar
com.jprok.performancetuning.ObjectCreationMonitoring -t
com.jprok.performancetuning.ProfileTest

Error occurred during initialization of VM
java.lang.StackOverflowError

I assume your question is how to get rid of this exception. Give your
app more memory (-Xmx<size>m).

robert
 
C

coltrane

Robert said:
I assume your question is how to get rid of this exception. Give your
app more memory (-Xmx<size>m).

robert


I tried -Xmx1000m and still got the the StackOverFlow. I tried a larger
number and received Invalid maximum heap size.

thanks

john
 
D

Daniel Dyer

I tried -Xmx1000m and still got the the StackOverFlow. I tried a larger
number and received Invalid maximum heap size.

thanks

john

You don't need more heap space, you need more stack space. Try -Xss.

Dan.
 
R

Robert Klemme

You don't need more heap space, you need more stack space. Try -Xss.

Ooops, yes. If that does not work, StackOverflowError might actually
indicate an endless recursion...

robert
 
C

coltrane

Robert said:
Ooops, yes. If that does not work, StackOverflowError might actually
indicate an endless recursion...

robert

I tried to run a helloworld app without the monitoring piece. So the
only thing I had was the addition of the modified Object class. I up'd
the heap and the stack and I still get a stack overflow. The change to
the Object class does look a little suspicious but I do not know enough
to determine if it would cause the failure. It is possible there are
errors in the book. hmmm, maybe I should look for any updates.

again the modifications to the Object class are the following additions

public Object(){
this(true);

if(com.jprok.performancetuning.ObjectCreationMonitoringFlag.monitoring)

com.jprok.performancetuning.ObjectCreationMonitoring.monitor(this);
}

public Object(boolean b)
{
}
thanks again for the feedback
 
R

Robert Klemme

coltrane said:
I tried to run a helloworld app without the monitoring piece. So the
only thing I had was the addition of the modified Object class. I up'd
the heap and the stack and I still get a stack overflow. The change to
the Object class does look a little suspicious but I do not know enough
to determine if it would cause the failure. It is possible there are
errors in the book. hmmm, maybe I should look for any updates.

again the modifications to the Object class are the following additions


public Object(){
this(true);

if(com.jprok.performancetuning.ObjectCreationMonitoringFlag.monitoring)

com.jprok.performancetuning.ObjectCreationMonitoring.monitor(this);
}

public Object(boolean b)
{
}

thanks again for the feedback

I don't know what that piece of code does but if it creates objects for
monitoring and if it does not prevent execution of itself for those
objects then indeed you may have an endless recursion.

robert
 
C

coltrane

Robert said:
I don't know what that piece of code does but if it creates objects for
monitoring and if it does not prevent execution of itself for those
objects then indeed you may have an endless recursion.

robert
objects then indeed you may have an endless recursion

my thought exactly. I would love to find someone who has actually gone
through some of these excercises.there are no corrections reported by
the author.

Oh well, on to the next problem

thanks for the help
 
T

Thomas Weidenfeller

coltrane said:
I tried to run a helloworld app without the monitoring piece. So the
only thing I had was the addition of the modified Object class. I up'd
the heap and the stack and I still get a stack overflow.

This is usually the moment where one considers attaching a debugger to
the application to find out if something does an endless recursion.

/Thomas
 
R

Robert Klemme

my thought exactly. I would love to find someone who has actually gone
through some of these excercises.there are no corrections reported by
the author.

Well, you might be able to detect this situation in the debugger if you
set a breakpoint on that StackOverflowError. If that does not help you
could print out the current stack trace every time you enter Object's
constructor.

Kind regards

robert
 
C

coltrane

Robert said:
Well, you might be able to detect this situation in the debugger if you
set a breakpoint on that StackOverflowError. If that does not help you
could print out the current stack trace every time you enter Object's
constructor.

Kind regards

robert

Well, from what I have seen I do not believe that the jvm likes having
the Object constructor defined. If I attempt to output anything in that
construct I get a stack error before I can debug it. If the constructor
is empty there is no problem. Once I try to use an object I get the
error. which seems to make sense in a way. I hate to give up on a
problem but I think I must move on.

thanks again for everyone's help

cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,828
Latest member
LauraCastr

Latest Threads

Top