This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Java Micro Edition and the fly likes Memory Exception!!! Help needed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "Memory Exception!!! Help needed " Watch "Memory Exception!!! Help needed " New topic

Memory Exception!!! Help needed

Somnath Das

Joined: Jun 06, 2006
Posts: 11
Hello Everyone,

Warm Greetings!,

I am building up an application, which is basically to do with File Transfer over Bluetooth.

When we run our application, on two devices, having one as sender and other as receiver, I get java.lang.MemoryOutOfException on the sender.

The logic I am using is, I am creating a array of byte and loading the entire file on a particular port, so that the client can receive the data from the Port. But, this doesn�t work, as it gives Memory Exception on the sender itself.

But, if we use the default bluetooth transfer on a mobile phone, any file size goes through without any problem.

I am trying to simulate the same device bluetooth transfer.

Can anyone please help me in solving, either my problem or my logic.

Thanks in advance,

Somnath Das

Sun Certified Java Programmer (1.4)<br /> <br />(Progress isn't made by early risers, But by lazy people, trying to find easier ways to do the same)
Isuru Sampath
Ranch Hand

Joined: Jun 26, 2003
Posts: 57
If you're getting an Out Of Memory error it could very well be due to a coding bug. Check whether you are having any conditions that will result memory leaks. You can use a profiler to detect this. Pay special attention to the conditions in your loops.

I am creating a array of byte and loading the entire file on a particular port
, why do you do this? you can obtain an input stream from the file for reading it. I don't see why do you need to load the whole file into a byte array. If your file is larger than the allocated heap (keep in mind that you are programming for a limited resource device), this could also result the same error.

No Winds No Waves
I agree. Here's the link:
subject: Memory Exception!!! Help needed
jQuery in Action, 3rd edition