This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
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
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)
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.