• Post Reply Bookmark Topic Watch Topic
  • New Topic

java out of memory during compile time  RSS feed

 
Arjun K
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need help to generate java Out of memory error during compile time.

Some thing like:
when I try to compile a java program with SUN JDK I should get an out of memory error.

One thing I have in mind now is importing more classes into my application as
import one;
import two;
.
.
.
import thousand;

Please hep me in this. Other than importing more classed; Is there any other way that forces the virtual machine into out of memory error during compile time ??
For information sake I am using jdk 1.5.0

Regards,
 
Horatio Westock
Ranch Hand
Posts: 221
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't have an answer. Can I ask why you want to do this?
 
Arjun K
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
we have developed an monitoring tool that do some thing on Out of memory situation. I just want to test whether its doing good on this situation.

I think you understood it.

Thanx in advance.
 
Horatio Westock
Ranch Hand
Posts: 221
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK. Roughly, how does your monitor work?
 
Arjun K
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont think I can explain in couple of words or sentences. Its moreover a project all toghter.

Moreover we used javax.management and java.management api's in implementing
this.

Will this helps you understand.

I repeat my requirement; which is to write an app which generates an out of memory during compile time. Does it related to any of the implementation and design of the project?

Let me know.

Thanx in advance.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

First, a bit of business: you may not have read our naming policy on the way in. It requires that you use a full, real (sounding) first and last name for your display name. "Handles" aren't acceptable, and a single name is not enough (although we would make an exception for Christo if he wanted to learn about Java.) You can change your display name
here.
Thanks!

Second, note that you can pass Java options to javac using the -J switch. So one way to force an OutOfMemoryError would simply be to give javac only a small heap to work with. I just tried it, and I can force an OutOfMemoryError while compiling a single trivial class by using

javac -J-Xms2m -J-Xmx2m Foo.java

The "-J-Xms2m -J-Xmx2m" limits the JVM running javac to 2 megs of Java heap -- the compiler can't get very far with that.
 
Arjun K
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Friedman-Hill,

I have changed my name according to the javaranch naming policy.

Coming to the solution that you proposed is more of giving java options with the javac command line. But my question is different; its rather an intentional generation of outofmemory during the compile time.

Hope you understood,

Thanx in advance.
 
Arjun K
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Friedman-Hill,

I was in a soup and missed some where. Sorry for incompleted previous reply.

It worked perfectly fine with your option.

Thanx for your reply,
 
Alexandru Popescu
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
He he ... probably this is why it is said not to speak with the mouth full .

--
:alex |.::the_mindstorm::.
 
Geoffrey Falk
Ranch Hand
Posts: 171
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try running javac from Ant with <javac fork="true" memoryMaximumSize="1m">

This will give javac a very small amount of memory to run in. It should be easy to get it to run out of memory.

Note: I have not tested this.

See http://ant.apache.org/manual/ for instruction on using Ant.

Geoffrey
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!