Hi All,
I am getting the out of memory error while calling the create image method.
The code snippet is the below and I am getting the exception while executing the last satement.
The image size is less 15 kb .
Image width*height=600*800.
And I am trying in the Nokia series 40 devices and getting the error while netbeans provided emulator its working fine.
But if the Image width*height<=480*640, then every thing is working fine.
I have checked the available heap memory and found that is available more than 800kb.Still getting the out of memory exception.
FileConnection fc = (FileConnection) Connector.open("file://localhost/" + imageFilePath);
if (!fc.exists()) {
throw new IOException("File does not exists");
} else {
InputStream fis = fc.openInputStream();
Image image = null;
ByteArrayOutputStream bStrm = new ByteArrayOutputStream();
byte imageData[] = new byte[2048];
while ((fis.read(imageData)) != -1) {
bStrm.write(imageData);
}
// Place into image array
imageData = null;
imageData = bStrm.toByteArray();
// Create the image from the byte array
fis.close();
fc.close();
image = Image.createImage(imageData, 0, imageData.length);
So can any one please tell me the reason of out of memory error!!!
Thanks & Regards,
Ajit

Reply With Quote


