Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4086692
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:45:36+00:00 2026-05-20T18:45:36+00:00

Is zLib Worth it? Are there other better suited compressors? I am using an

  • 0

Is zLib Worth it? Are there other better suited compressors?

I am using an embedded system. Frequently, I have only 3MB of RAM or less available to my application. So I am considering using zlib to compress my buffers. I am concerned about overhead however.

The buffer’s average size will be 30kb. This probably won’t get compressed by zlib. Anyone know of a good compressor for extremely limited memory environments?

However, I will experience occasional maximum buffer sizes of 700kb, with 500kb much more common. Is zlib worth it in this case? Or is the overhead too much to justify?

My sole considerations for compression are RAM overhead of algorithm and performance at least as good as zlib.

LICENSE: I prefer the compressor be licensed under BSD, zLib, or equivalent license.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T18:45:36+00:00Added an answer on May 20, 2026 at 6:45 pm

    If you initialize zlib with lm_init() with 1, 2, or 3, the deflate_fast() routine will be used instead of deflate(), which will use smaller runtime buffers and faster algorithms. The tradeoff is worse compression. It is probably worth it.

    If you compile zlib with SMALL_MEM defined, it will use smaller hash buckets when hashing input strings. The documentation (in deflate.c) claims:

    /* Compile with MEDIUM_MEM to reduce the memory requirements or
     * with SMALL_MEM to use as little memory as possible. Use BIG_MEM if the
     * entire input file can be held in memory (not possible on 16 bit systems).
     * Warning: defining these symbols affects HASH_BITS (see below) and thus
     * affects the compression ratio. The compressed output
     * is still correct, and might even be smaller in some cases.
     */
    

    Hopefully, these two techniques combined can bring zlib into range with your application. It’s a ubiquitous standard, and being able to re-use well-worn components may be worth sacrifices elsewhere in the application. But if you know something about the distribution of your data that allows you to write your own compression routines, you may be able to do better, but you can drop zlib in place quickly — writing and testing your own might take more time.

    Update

    Here’s some output on a zlib built with SMALL_MEM, using different compression level settings, on the first 600k file I found:

    $ ls -l abi-2.6.31-14-generic
    -rw-r--r-- 1 sarnold sarnold 623709 2011-03-18 18:09 abi-2.6.31-14-generic
    $ for i in `seq 1 9` ; do /usr/bin/time ./gzip -c -${i} abi-2.6.31-14-generic | wc -c ; done
    0.02user 0.00system 0:00.02elapsed 76%CPU (0avgtext+0avgdata 2816maxresident)k
    0inputs+0outputs (0major+213minor)pagefaults 0swaps
    162214
    0.01user 0.00system 0:00.01elapsed 52%CPU (0avgtext+0avgdata 2800maxresident)k
    0inputs+0outputs (0major+212minor)pagefaults 0swaps
    158817
    0.02user 0.00system 0:00.02elapsed 95%CPU (0avgtext+0avgdata 2800maxresident)k
    0inputs+0outputs (0major+212minor)pagefaults 0swaps
    156708
    0.02user 0.00system 0:00.02elapsed 76%CPU (0avgtext+0avgdata 2784maxresident)k
    0inputs+0outputs (0major+211minor)pagefaults 0swaps
    143843
    0.03user 0.00system 0:00.03elapsed 96%CPU (0avgtext+0avgdata 2784maxresident)k
    0inputs+0outputs (0major+212minor)pagefaults 0swaps
    140706
    0.03user 0.00system 0:00.03elapsed 81%CPU (0avgtext+0avgdata 2784maxresident)k
    0inputs+0outputs (0major+211minor)pagefaults 0swaps
    140126
    0.04user 0.00system 0:00.04elapsed 95%CPU (0avgtext+0avgdata 2784maxresident)k
    0inputs+0outputs (0major+211minor)pagefaults 0swaps
    138801
    0.05user 0.00system 0:00.05elapsed 84%CPU (0avgtext+0avgdata 2784maxresident)k
    0inputs+0outputs (0major+212minor)pagefaults 0swaps
    138446
    0.06user 0.00system 0:00.06elapsed 96%CPU (0avgtext+0avgdata 2768maxresident)k
    0inputs+0outputs (0major+210minor)pagefaults 0swaps
    138446
    

    The entire gzip program takes around 2.6 megabytes of memory, regardless of the compression level asked for; perhaps just using the specific functions you need rather than the entire gzip program would bring that number down some, but it might be too expensive for your little machine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there some magic required to obtain a zlib sync flush when using boost::iostreams::zlib_compressor
I am building using zlib.h which I have a local copy to v1.2.5, but
In particular I am using a Ionic.Zlib.ZlibStream to do Zlib compression on a System.Net.Sockets.NetworkStream
I'm trying to use Zlib::Deflate.deflate on a massive file (4 gigs). There are obvious
Can anyone tell me the difference between using mod_deflate and zlib output_compression? I understand
Note: I had another similar question about how to GZIP data using Ruby's zlib
In Django Design Patterns , the author recommends using zlib.crc32 to mask primary keys
I am using zlib to compress a stream of text data. The text data
I downloaded zlib.NET and there's a file that I must import,its named zlib.net.dll. My
I have zlib and Zend Optimizer enabled on my server and I have read

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.