• Post Reply Bookmark Topic Watch Topic
  • New Topic

Memory Exception!!! Help needed  RSS feed

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,

Regards,
Somnath Das
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!