|
Hello Sir
It is giving error:
Exception in Thread :java.lang.outofmemoryerror :java heap space.
i setted virtal memory to 4096m
And in Netbeans isetted to -Xms2048m -Xmx2048m
Thanks For ur Reply
Regards
Yogesh
|
|
|
|
|
The first thing to be aware of is that if you are running under Windows, you won't be able to use much more than 1Gb of memory for your Java heap space (certainly true for 32 bit, may be different for 64 bit Windows). The reason is that the Sun JVM requires heap memory to be allocated contiguously (in other words, in one big continuous block of memory). Because of the way Windows loads DLLs into memory, Windows can't normally allocate contiguous blocks of memory bigger than roughly 1 gig (off the top of my head the figure that springs to mind is 1.2Gb but that may be wrong). You can do things like shuffling DLLs around but even then you don't get a lot more and it's probably not worth the effort. Things may be different with 64 bit Windows, I don't know because I've not worked with it very much yet. Things may also be different with other JVMs (I used to use JRockit 5 years ago with WebLogic and that was the same at the time, but I believe that now it no longer requires contiguous memory and so does not suffer from this problem.)
But I would turn this question around: what are you doing that is blowing so much memory so quickly? It sounds to me as if there is something amiss here and instead of throwing more memory at the problem, maybe you could reconsider your design?
|
|
|
|
|
Hello David Sir
Actually the design demands for this type of memory requirement.I have to load a file dynamically with initialisation whose size is around 3.5MB.
But If I load file around 1mb then its working.So to load heavy file I increased the heap space to 2048 then it is not running even thru netBeans,error comes like
Could not create the Java virtual machine.
Error occurred during initialization of VM
Could not reserve enough space for object heap
Java Result: 1
Thanks For ur reply.
Any Ideas?
Regards
Yogesh
|
|
|
|
|
Any Other Ideas Guys??????
I think i made it very confusing.let me Explain u in better way.
The Simple thing is that When I set Heap Space -Xms1024m -Xmx1024 then its working fine. But As I increased to -Xms2048m -Xmx2048 then when I try to run thru NetBeans even It gives me the Error:
run:
Error occurred during initialization of VM
Could not create the Java virtual machine.
Could not reserve enough space for object heap
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
What do i Need to change to increase Heap Space.
And If I run thru batch file in which I specify
java -Xms512m -Xmx1024m -jar sample.jar
Thanks & Regards
Yogesh
|
|
|
|
|
Re-read my earlier post. On a Win32 platform, you will not be able to allocate more than about 1.2Gb for the heap size.
Question: What do I need to change to increase heap size?
Answer: The operating system
You say that you are having a problem loading a 3.5Mb file into 1Gb of heap space. Something is not right there. What are you doing with this file that is causing it to consume so much memory?
|
|
|
|
|
Ok,i agree with u that I cant give more than 1.2gb heap size on win32 OS But When I run thru Batch file then How it load the same 3.5Mb file?
Yeah,I am reading and parsing that file.
One last Question:What is the difference between running viewer through NetBeans and Running through Directly jar file?How it loads in both way?Any Documentation or If u know tht would b much better.
Thanks & regards
Yogesh
modified on Wednesday, June 23, 2010 8:20 AM
|
|
|
|
|
What "viewer" are you talking about and what kind of file is this that you are parsing?
And are you now saying that you can load this file if you run it via a batch file as opposed to running it within NetBeans?
|
|
|
|
|
Hello Sir
Viewer is application that I created to load some 3d files(.obj files).
I think I again confused the scenario or u misunderstood.am sory for that.
Here are the Things:
Now Heap Space is set to -Xms1024m -Xmx1024m.
This one is loading each and every file If I run thru Netbeans.
If I run by directly clicking jar file then its not loading heavy file.
But If I run the same jar file with the help of batch file then it is loading heavy files too.
Now,I want to load heavy files with the click of jar file only.
Thanks & Regards
Yogesh
|
|
|
|
|
I understand now, sorry, I was a bit slow on the uptake there.
As far as I am aware, there is no way to set the heap size for executable jar files. If you run the jar by double-clicking, it will use the default heap size for the JVM and you cannot override this in the jar manifest. By the time the jar loads and the manifest is read, the JVM has started and the heap size has been allocated.
So, your options are:
- If you can live with launching via a batch file, use javaw to set the -Xms and -Xmx values and run the jar using the -jar switch (this is possibly the most usual way to do it).
- If you really must have an executable jar file that you can double click to run, create a small Java program, all that does is to set up the javaw command line with the parameters you want to invoke your main jar, then execute that via Runtime exec (which would work but it's a bit of a hack)
- If you don't like that clunky approach, write a little launcher exe in some other language (C, Python, whatever). This is another common way to do things. (I believe this is how NetBeans does it, although I might be wrong there).
- Use one of the Java to exe tools (something like launch4j). I have never used any of these, so if you go down that route I cannot advise you which is best, or what the pitfalls are.
|
|
|
|
|
Ok,I will try any one of option from these.
And Thanks For ur time and Help.
Thanks Once Again.
Regards
Yogesh
|
|
|
|
|
IAM WORKING WITH FTL. my requirement is in my ftl i have one text field , i need to input date into that field and do validate on that by using the f allowing the conditions
format should be yyyy-mm-dd, restrict is not accept other than 10 characters
year: 2000>yyyy<3000
Month: 1>mm<12
Day: 1>dd<<31, based on this display message for wrong entry
where i need to write this conditins, plz send me urgent.
|
|
|
|
|
Some suggestions first:
1. Please format your message properly because it is almost unreadable. What's with all those spaces everywhere? And please don't write full sentences in uppercase, this is considered rude.
2. People here are not paid to answer questions, so don't ask "plz send me urgent". This is also considered very rude.
Now to your question. What is FTL exactly ?
Anyway, as far as I understood, you have a String containing a date with a specific format, and you would like to check that the format is correct. Am I right ?
If yes, have a look at the SimpleDateFormat[^] class, and its parse method.
|
|
|
|
|
HI ,
I am new to java programming.
We have a website in which login file is to be implemented with "Remember password" functionality. Please guide me how to do it.
|
|
|
|
|
Here[^] are some potential solutions.
It's time for a new signature.
|
|
|
|
|
Hi
I need to encrypt the plan text using AES algorithm in java and decrypt the encrypted text using C.Any please give solution ASAP.
Thanks
|
|
|
|
|
You could do worse than starting here[^] with your encryption. I'm sure it would not take too long to find the corresponding C code for the decryption phase.
It's time for a new signature.
|
|
|
|
|
Hey guys
I have another elementary problem that needs solving. In the program, after you enter your date of birth (e.g. 14/08/1977), the program takes the month out, and gives you a vacation period in that month.
I'm using a long if statement, with a string value assigned to each month. The if statement pretty much goes if, else if, else if...and so on. Am I using the substring method incorrectly?
if(DOB.substring(3,5) == "01")
{
System.out.println("Holiday Month: " + month1 + "\n" + "Days: " + DOB.substring(3,5));
}
|
|
|
|
|
CodeScribbler wrote: Am I using the substring method incorrectly?
Not as far as I can see (see here[^]). However your output string will show the month number after the "Days: " field; this may not be what you want.
It's time for a new signature.
|
|
|
|
|
Your use of substring is correct, but the test for the String value is not:
DOB.substring(3,5) == "01"
This is wrong because you are testing to see if DOB.substring(3,5) and "01" are the same object instance. In fact, they are not. They are two different String objects so even if they both have the same value this test will return false. You want to use the equals method to test the String value.
String s1 = new String("01");
String s2 = new String("01");
if (s1 == s2)
if (s1.equals(s2))
|
|
|
|
|
Thanks David...that makes a whole lot more sense now!
This website is a great resource, and I appreciate the help. Software is the core of the computer industry. Ok well, that's another huge debate...
I've been studying programming for two years now, and I'm really loving it. A friend recommended this website to me, and I've yet to feel disappointed. I'm glad there are a few knowledgable (and willing) people to help out here!
I good friend once told me once that, "A sign of a good programmer, is someone who'll work an eight hour job. He'll come home, have dinner, and get behind his computer and continue coding."
Just a thought
|
|
|
|
|
Hi
I've been facing problems with this new type of connection, and I want some examples on how to establish a serial connection between my phone (SE w910i) and my laptop, through bluetooth. I'm not an expertise on this topic, even on this programming language. It was better if I could make java applets in C#
|
|
|
|
|
Hi guys,
I have had some java software written for me that hits a web address and passes through a date/time value in the format of:
YYYYMMDDHHmmSS
Most of the time the date/time comes through correctly... but for some reason it "randomly" sends a through date/time values that are 50 days in the future...
The data gets sent through every 15 seconds and the data will be correct at 10:00:00 but then 15 seconds later I'll get 17:30:22 50 days in advance... and then the date/time value increments by 15 seconds, but still 50 days the future... it will also then "randomly" come good again... now this isn't an odd one here and there, it's right for a while, then will run the rest of the day sending the wrong time...
Does this make sense...???
The problem is I can't reproduce it at will... I know, I know, I'm a programmer and that is the first thing I ask my users to do.. Give me repro steps... but I can't figure out how to reproduce it...
I've tried setting the phone date/time back to a time just before when it has happened in the past, but then the software just works.. it sends the correct time values right through the previous problem window...
Now the only other thing I could think of was that the phone does something "odd" with time calculations or stores the date/time in a funny way internally that wouldn't be necessarily visible to the developer...
I'm clutching at anything I can at the moment because my boss is starting to get shirty about this bug...
Here is the code that I'm told is being used to formulate the date/time value ready for sending via the URL:
private String getTimestamp() {
String time = "00000000000000";
try {
Calendar ca = Calendar.getInstance();
ca.setTime(new Date(System.currentTimeMillis()));
int year = ca.get(Calendar.YEAR);
String syear = Integer.toString(year);
int month = ca.get(Calendar.MONTH) + 1;
String smonth = month < 10 ? "0" + Integer.toString(month) : Integer.toString(month);
int day = ca.get(Calendar.DAY_OF_MONTH);
String sday = day < 10 ? "0" + Integer.toString(day) : Integer.toString(day);
int hour = ca.get(Calendar.HOUR_OF_DAY);
String shour = hour < 10 ? "0" + Integer.toString(hour) : Integer.toString(hour);
int min = ca.get(Calendar.MINUTE);
String smin = min < 10 ? "0" + Integer.toString(min) : Integer.toString(min);
int second = ca.get(Calendar.SECOND);
String ssecond = second < 10 ? "0" + Integer.toString(second) : Integer.toString(second);
time = syear + smonth + sday + shour + smin + ssecond;
} catch (Exception e) {
}
return time;
}
As stated in the Subject here... this is happening on two different Nokia 2323 phones... unfortunately I don't have another nokia phone to test this on to see if its a specific 2323 problem or a Nokia problem...
HELP ME PLEASE..!!!!
If anyone has a suggestin, no matter how crazy, I'm willing to try it out...
Has anyone ever come across this issue before...
If you need more clarification or have questions... shoot them through...
Thanks
** I'm not crazy.. Just ask my toaster **
|
|
|
|
|
I've run your code on my PC and it seems to work fine. The only thing I can suggest is to check the value returned from System.currentTimeMillis() which is being used to seed the calendar object.
It's time for a new signature.
|
|
|
|
|
G'day,
Thanks for the quick reply...
The code does work most of the time.. that's the problem... it'll work for minutes/hours/days, so a quick couple of tests will probably return a correct answer...
What do you mean to "check the value returned from System.currentTimeMillis()"...???
Is there a "better" value to use...???
Why does the calendar object need a seed value...??? I'm a vb.net developer so please excuse my ignorance in this langauge and forum..
Thanks
|
|
|
|
|
Member 2119945 wrote: Why does the calendar object need a seed value...???
It doesn't. By default, Calendar.getInstance() will return a calendar object initilised to the current date and time, using the current timezone and locale. The J2ME Calendar is a cut-down version of the J2SE class with some methods removed but it has the same default constructor.
Member 2119945 wrote: What do you mean to "check the value returned from System.currentTimeMillis()"...???
Well, the code that you have posted looks correct, there are no errors in the code. So, if there is nothing wrong with the code, the obvious next point to investigate is the value which you are using to seed the calendar. If you put the wrong value in at the start of the process, you will get the wrong value out at the end.
Is it possible that for some reason System.currentTimeMillis is returning the wrong value? Not sure why that would happen (time zones?), but I agree with Richard and that would be the next thing I check. That's not so easy to do if this is happening unpredictably, I agree.
Maybe you could search the Nokia S40 forums to see if anyone else has any issues with currentTimeMillis (S40 may not be the correct platform for this phone type - I'm not sure but you get the idea).
|
|
|
|