java - How to decompress a RAR file in Android application with out of memory exception? -


i writing android application decompressing rar files of junrar library. during decompression of type of rar files, out of memory exceptions occur.

could please me resolve issue.

i know, there problem junrar library, if found solution, please let me know.

my analysis:

if rar file compressed ppm algorithm, out of memory exception occurs because attempt made allocate more memory android device vm has.

startsuballocator allocating more memory android vm has new byte [100] mb bytes. exceeds available ram of 96 mb of android vm.

logs attached

java.lang.outofmemoryerror  com.github.junrar.unpack.ppm.suballocator.startsuballocator(suballocator.java:146) com.github.junrar.unpack.ppm.modelppm.decodeinit(modelppm.java:216) com.github.junrar.unpack.unpack.readtables(unpack.java:656) com.github.junrar.unpack.unpack.unpack29(unpack.java:165) com.github.junrar.unpack.unpack.dounpack(unpack.java:120) com.github.junrar.archive.doextractfile(archive.java:500) com.github.junrar.archive.extractfile(archive.java:442) com.github.junrar.testutil.extractarchive.extractarchive(extractarchive.java:73) com.github.junrar.testutil.extractarchive.extractarchive(extractarchive.java:29) com.letusread.util.decompressutil.decompress(decompressutil.java:140) com.letusread.activity.filelistactivity$7.run(filelistactivity.java:338) java.lang.thread.run(thread.java:856) 

help of winrar contains on page title advanced compression parameters explanation:

text compression/memory use, mb
memory in megabytes allocated ppm (can 1-128). higher values may increase compression ratio, note ppm uses equal memory size both compress , decompress, if allocate memory when creating archive, other people may have problems when unpacking on computer less memory installed. if field set 0, winrar choose memory size automatically.

the page title switch -mc - set advanced compression parameters , text file rar.txt (manual console version) contain similar statement on memory requirements advanced text compression.

128 mb of free (perhaps continuous) memory needed unpacking rar archive created using advanced text compression 128 mb memory usage. nothing can done extract files such rar archive if there not enough free memory.


text file rar.txt contains information memory requirements solid archives on compression , decompression (switch -md):

for rar 4.x archive format dictionary size can be:
64 kb, 128 kb, 256 kb, 512 kb, 1 mb, 2 mb, 4 mb.

for rar 5.0 archive format dictionary size can be:
128 kb, 256 kb, 512 kb, 1 mb, 2 mb, 4 mb, 8 mb, 16 mb, 32 mb, 64 mb, 128 mb, 256 mb, 512 mb, 1 gb.

when archiving, rar needs 6x memory of specified dictionary size, 512 mb , 1 gb sizes available in 64 bit rar version only. when extracting, more single dictionary size allocated, both 32 , 64 bit versions can unpack archives dictionaries , including 1 gb.


to answer question: cannot in application if rar archive created on windows pc using excessive memory , there not enough free memory decompression. alternate decompression algorithms less memory usage rar archives not exist.


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -