aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_buffers.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-11-17 11:43:50 -0500
committerNick Mathewson <nickm@torproject.org>2014-11-17 11:43:50 -0500
commit734ba5cb0a0b6cc5376f8889305835224d814252 (patch)
tree78fa73f2248c8cea20426c5d70c5811d5765de58 /src/test/test_buffers.c
parenta68b90fc7af401220f11f4f9e39f08a8548a6957 (diff)
downloadtor-734ba5cb0a0b6cc5376f8889305835224d814252.tar.gz
tor-734ba5cb0a0b6cc5376f8889305835224d814252.zip
Use smaller zlib objects when under memory pressure
We add a compression level argument to tor_zlib_new, and use it to determine how much memory to allocate for the zlib object. We use the existing level by default, but shift to smaller levels for small requests when we have been over 3/4 of our memory usage in the past half-hour. Closes ticket 11791.
Diffstat (limited to 'src/test/test_buffers.c')
-rw-r--r--src/test/test_buffers.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/test/test_buffers.c b/src/test/test_buffers.c
index cb29ab0a9e..e24aa8ec86 100644
--- a/src/test/test_buffers.c
+++ b/src/test/test_buffers.c
@@ -611,7 +611,7 @@ test_buffers_zlib_impl(int finalize_with_nil)
int done;
buf = buf_new_with_capacity(128); /* will round up */
- zlib_state = tor_zlib_new(1, ZLIB_METHOD);
+ zlib_state = tor_zlib_new(1, ZLIB_METHOD, HIGH_COMPRESSION);
msg = tor_malloc(512);
crypto_rand(msg, 512);
@@ -688,7 +688,7 @@ test_buffers_zlib_fin_at_chunk_end(void *arg)
tt_uint_op(buf->head->datalen, OP_EQ, headerjunk);
tt_uint_op(buf_datalen(buf), OP_EQ, headerjunk);
/* Write an empty string, with finalization on. */
- zlib_state = tor_zlib_new(1, ZLIB_METHOD);
+ zlib_state = tor_zlib_new(1, ZLIB_METHOD, HIGH_COMPRESSION);
tt_int_op(write_to_buf_zlib(buf, zlib_state, "", 0, 1), OP_EQ, 0);
in_len = buf_datalen(buf);