aspose file tools
The moose likes Java in General and the fly likes OutOfMemoryError extracting from ZIP file Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "OutOfMemoryError extracting from ZIP file" Watch "OutOfMemoryError extracting from ZIP file" New topic
Author

OutOfMemoryError extracting from ZIP file

Garret Schweitzer
Greenhorn

Joined: Dec 27, 2005
Posts: 4
Howdy all,

I have a Java issue and I don't know how to solve it, so I thought I'd run it by the folks here and see if anyone here knows what to make of it.

First: The (simplified) code below works fine on a PC, but not in a limited memory environment, like a PDA.

Second: I have no control over the Java environment, so I can't control startup switches. In fact, I'll be running in a WebSphere environment. This code will be running in a J2ME environment as well as a J2SE and J2EE environment, so it needs to be friendly.

The problem: It runs out of memory when inflating a large file (greater than ten megs) from a ZIP. If I have 14 files in the ZIP and two are larger than ten megs, it will inflate all but the two large ones.

Where it does NOT occur: Strangely enough, it doesn't happen at a controllable place, like a buffered read. It isn't happening at any place where I can control the number of bytes read.

Where it DOES occur: It's happening at the line where I try to get the input stream getInputStream() for an entry in the ZIP file. Specifically, the large (greater than ten megs) entry in the file.

Why it happens: I have some theories. 1) It may be standard practice to read the entire file during a getInputStream() method call. 2) In order for the inflator to determine strategy, it may have to read the entire file. 3) The blocksize for the stream is determined in some way by the size of the file.

What you can do to help me: If you know the answer, great, let me know. I need to finish this project. ALSO, tell me how I can find this stuff out on my own. If there is some method of seeing the source code behind getInputStream() in java.util.zip.ZipFile, that might lend some clues. Perhaps looking at the bytecode would be handy...if I knew how to intrepret it. If there is a workaround that is more memory-friendly, that would be outstanding. I'm easy.

I'm going to post code at the end of this message.

Thanks in advance for help.

Garret




Jessica Sant
Sheriff

Joined: Oct 17, 2001
Posts: 4313

Garret-
Please don't post the same question in multiple forums, it makes the conversation difficult to follow and wastes people's time when the question has already been answered elsewhere.

So, please post your replies here in the original thread.

Thanks!
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: OutOfMemoryError extracting from ZIP file
 
Similar Threads
OutOfMemoryError when accessing Zip File
Problem unzipping with ZipInputStream, containing filename with Swedish characters
unzip problem, I give up now
UnZip error
OutOfMemoryError using getInputStream()