top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is OutOfMemeryError injava?how to deal with java lang.OutOfMemeryError error?

0 votes
229 views
What is OutOfMemeryError injava?how to deal with java lang.OutOfMemeryError error?
posted Feb 17, 2016 by Karthick.c

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

you always have a finite max of heap to use no matter what platform you are running on and same with java happens.Recently I got this error while drawing bitmap in android studio just because it was increasing the allotted heap memory.I changed the dimensions and after that error was solved.
Try to run your programs with -Xmsn to give maximum heap memory to your program.
Example:

->   -Xmx50m

to allocate 50MB memory.
For better understanding follow this link : http://docs.oracle.com/javase/7/docs/technotes/tools/windows/java.html#nonstandard

answer Mar 10, 2016 by Shivam Kumar Pandey
Similar Questions
+5 votes

I have used below code,

textareaA.addTextChangedListener(new TextWatcher() {
    @Override
    public void afterTextChanged(Editable arg0) {
    }

    @Override
    public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
    }

    @Override
    public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
        double val = Double.parseDouble(textareaA.getText().toString());
        textareaB.setText(String.valueOf(val/10000));
    }      
});

textareaB.addTextChangedListener(new TextWatcher() {
    @Override
    public void afterTextChanged(Editable arg0) {
    }

    @Override
    public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
    }

    @Override
    public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
        double val = Double.parseDouble(textareaB.getText().toString());
       textareaA.setText(String.valueOf(val*10000));
    }      
});

If I type a value in any EditTexts, it crashes and trows java.lang.StackOverflowError error.
Suggest a solution.

0 votes

I run my code in Eclipse IDE and its fine. I have export it as jar file from Eclipse and run on terminal as jar file, it generates Error: java.lang.NullPointerException. Could not understand why is it so.

–2 votes

Write java program that deal with different shapes. Shapes mean geometry shapes i.e. circle, rectangle, square, and triangle.

Circle: radius
Rectangle: height and width
Square: height
Triangle: base and height

All shapes have area but each shape has specific way for calculating the area:

Circle: ½ pie square *radius
Rectangle: height * width
Square: height * height
Triangle: ½ base *height

Finally, in the main program
1. Define all different kinds of shapes
2. Call Area method for all objects and print result .

+2 votes

Did any one got these error before, please help

ERROR org.apache.hadoop.hdfs.server.datanode.DataNode: xxxxx.com:50010:DataXceiver error processing WRITE_BLOCK operation  src: /xxxxxxxx:39000 dst: /xxxxxx:50010

java.lang.NullPointerException
at org.apache.hadoop.hdfs.server.datanode.BlockReceiver.(BlockReceiver.java:167)
at org.apache.hadoop.hdfs.server.datanode.DataXceiver.writeBlock(DataXceiver.java:604)
at org.apache.hadoop.hdfs.protocol.datatransfer.Receiver.opWriteBlock(Receiver.java:126)
at org.apache.hadoop.hdfs.protocol.datatransfer.Receiver.processOp(Receiver.java:72)
at org.apache.hadoop.hdfs.server.datanode.DataXceiver.run(DataXceiver.java:225)
at java.lang.Thread.run(Thread.java:745)
2015-01-11 04:13:21,846 WARN org.apache.hadoop.hdfs.server.datanode.DataNode: IOException in offerService
WARN org.apache.hadoop.hdfs.server.datanode.DataNode: Slow BlockReceiver write packet to mirror took 657ms (threshold=300ms)
...