• Post Reply Bookmark Topic Watch Topic
  • New Topic

Out of memory  RSS feed

 
Rajan Venkat
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have scenario in which i get the OutOfMemory Exception.

Let me say what i am doing, I have a PDA which is WM2005 device.I am downloading the GZIP compressed file from the server and i am dumping this file in the cache disk or external memory(SD) ,the size of the compressed file is 675KB ,if i uncompress it ,the size would be 17MB.

Here is my question,

I get Memory problem ,when i uncompress the file at runtime like this


and i am reading the primitive value out of the stream.

Now i thought of doing like ,
1) Dumping the compressed file in the external memory .
2) Uncompressing or extracting the file in the same external memory.
3) Processing the data from the uncompressed file.

Can anyone of you suggest if i go for the second approach ,will i solve the out of memory propblem and please let me know the difference in decompressing the file at runtime and reading the data from the uncompressed file?
 
K Kiran Kumar
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Venkat,

First try using System.gc(). If this doesn't work, increase the virtual memory to get rid or out of memory errors.

You can increase the virtual memory by using "java -Xmx512m" command. You can try out even keeping "java -Xmx1024m"....
or
You can set this in java control panel, you can go through the following link with a video which shows how to set it:
http://www.auditmypc.com/java-memory-xmx512.asp

Regards,
Kiran.
 
Joe Ess
Bartender
Posts: 9439
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by K Kiran Kumar:
You can increase the virtual memory by using "java -Xmx512m" command. You can try out even keeping "java -Xmx1024m"....


Did you read Rajan's post? His program is running on a PDA. It probably doesn't have 512mb RAM. And invoking System.gc() is rarely helpful (and can impede performance).
Rajan, your code leaves much to the imagination. Are you attempting to extract the file to memory, then process it? Probably a Bad Idea. Can you read a small chunk of the file, process it, then discard it and retrieve another? That would be much easier on memory use.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is in the compressed zip file?

Perhaps there is a more compact way to represent the data to reduce the memory needed to unpack it. For example, if it is characters in the ASCII (0-128) range, a byte[] will take half the space that String representation takes.

Bill
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!