Bhay Zone

Greenhorn
+ Follow
since Jul 13, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Bhay Zone

Couple of things

If, after setting the values you were doing some expensive computations (in the same method) AND there are 100s or 1000s of threads executing the same code concurrently, then there could be memory issues. Otherwise I do not see any performance issues.

Just for ease of maintainability, I would do this.

int i=0;
String name = messages[i++];
String address = messages[i++];
..
..
..

Why?
Just imagine if you had to add a color attribute somewhere in the middle of your message array.

Again, in the interest of maintainability, I would provide a constructor to the MyBean class with a String[] parameter. This, so that the semantics of creation of this bean are present in a single location. I would not want the code for populating this bean to be spread throughout the application.

Just my 2 cents.

12 years ago
"We have analyzed the heap dump files and it says the "OutOfMemory" Exception and much memory took for this STATIC Logger instantiation."

how did you find that the static logger was taking most of the memory?

This seems highly unlikely unless you start your application will really low parameters for the PermGen space. Class objects and class variables (i.e. static members) are stored in the PermGen area of the heap. This area is not subject to garbage collection. So if it is truly the static logger that is causing an OutOfMemoryError, then the only explanation is that you are allocating very little memory for the PermGen during your server startup.

See if this link helps
http://www.brokenbuild.com/blog/2006/08/04/java-jvm-gc-permgen-and-memory-options/

12 years ago
The error is thrown when the garbage collector is unable to free up enough space to allow allocation to the requested object.

So basically when a new object is to be created and there is not enough space in the heap, the jvm will invoke the garbage collector. If after the gc completion, there is still not enough space freed up, then the jvm throws an OutOfMemoryError: java heap.

Note that even though your post mentions "java heap space", there are a few other types of OutOfMemoryErrors that the JVM can throw.

1) OutOfMemoryError - when not enough memory can be allocated for a new array
2) OutOfMemoryError - when not enough memory is available for your class to load
3) OutOfMemoryError - when too many threads / not enough stack space available for a new thread
4) StackOverFlowError - when you have exceed the maximum space on the stack.
12 years ago
I am guessing you mean PackedDecimal. I'm not sure how you are parsing the numbers, but from your examples it looks like your parser is parsing a '2' digit as '1'. My guess is that you are converting each digit from the mainframe into a 4 bit binary and then reconverting the binary to decimal. If this is what you are doing, then look at the code that converts the digit '2' into binary. It might incorrectly be converting '2' to 0001 instead of 0010.
14 years ago

David Newton wrote:I've had the same problem using non-1024m multiples.



I'm not sure if this will help, but I found this on java.sun.com. It says that the memory arg has to be a multiple of 1kb i.e. 1024 greater than 2MB.

http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/java.html

14 years ago
Hi Jeanne,

Apologize for replying so late, and that too for my own query. Sorry again.

I figured out the problem and you were right, the string array is the right approach. However what I was doing wrong in my failed string array attempt was that I declared the expression and its flag as a single array element "--expr (last-modified > "2009-06-15\". The right way to do it is to split that into two separate element i.e. {"query-pr", " ...", "...", "--expr", "(last-modified > "2009-06-15\")"}.

Thanks a lot for your help.


Jeanne Boyarsky wrote:Bhay,
The string array is the approach that should work.

Is this exactly what you tried? (It's missing quotes around the --expr" parameter and the parameter/value should be separate arguments.) What error did you get with this approach?

14 years ago

Help !!!

I am trying to invoke a command from my java program running under Redhat Linux using Java 1.6. The command i'm trying to execute is actually a shell script that executes a query on a remote system (GNATS - a bug tracking tool).

I need to execute the following command through my java program.
query-pr --host mygnatsdb.dom.net --port 1568 --expr '(last-modified > "2009-06-15")'

When I run this command directly at the command prompt, it executes fine.
However, if I run it from java, the tool complains that the query expression is Invalid. Somehow its not able to parse the expression passed in the last argument.

1] Escaping the quotes does not work. Same results.

2] I tried double escaping them (--expr '(last-modified > \\\"2009-06-15\\\")') thinking that java is doing some sort of parsing again before actually invoking my command, but that ended in the same result.

3] I cannot use single quotes as they are being used at the begingin to mark the start and end of the query expression, and switching between them is not allowed.

4] I tried using the exec(String[] cmdarray) method, however I'm not sure if I used it correctly, because it did not work. Tried several variations.
String cmdarr[] = {"query-pr", "--host", "spyro.juniper.net", "--port", "1528", --expr '(last-modified > \"2009-06-15\")};
Runtime.exec(cmdarray).

Now I have reached my wits end and can't seem to make any progress. Please help !!!

Bhay.
14 years ago