Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2006

Tip: Looking for answers? Try searching our database.

Performance tuning - Object Creation

Thread view: 
coltrane - 25 Sep 2006 14:31 GMT
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
Robert Klemme - 25 Sep 2006 14:33 GMT
> This is the command line and the error output:
>
[quoted text clipped - 5 lines]
> 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
coltrane - 25 Sep 2006 14:43 GMT
> > This is the command line and the error output:
> >
[quoted text clipped - 10 lines]
>
>     robert

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

thanks

john
Daniel Dyer - 25 Sep 2006 14:53 GMT
>> > This is the command line and the error output:
>> >
[quoted text clipped - 18 lines]
>
> john

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

Dan.

Signature

Daniel Dyer
http://www.dandyer.co.uk

Robert Klemme - 25 Sep 2006 15:45 GMT
>>> > This is the command line and the error output:
>>> >
[quoted text clipped - 21 lines]
>
> 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
coltrane - 25 Sep 2006 18:08 GMT
> >>> > This is the command line and the error output:
> >>> >
[quoted text clipped - 26 lines]
>
>     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
Robert Klemme - 25 Sep 2006 20:27 GMT
> 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
[quoted text clipped - 18 lines]
>
> 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
coltrane - 25 Sep 2006 21:11 GMT
> > 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
[quoted text clipped - 24 lines]
>
>     robert

>>and if it does not prevent execution of itself for those
> 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
Robert Klemme - 26 Sep 2006 12:29 GMT
>> 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
[quoted text clipped - 6 lines]
> 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
coltrane - 26 Sep 2006 18:24 GMT
> >> 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
[quoted text clipped - 15 lines]
>
>     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
Thomas Weidenfeller - 26 Sep 2006 08:31 GMT
> 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
Signature

The comp.lang.java.gui FAQ:
http://gd.tuwien.ac.at/faqs/faqs-hierarchy/comp/comp.lang.java.gui/
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.