Reduce memory requirements for regression tests.
This is intended to drop memory usage to a level that AppVeyor test instances can handle. This resolves #393.
This commit is contained in:
parent
eaecaad8ea
commit
b99c72f3d2
@ -1,7 +1,20 @@
|
|||||||
#include "test/jemalloc_test.h"
|
#include "test/jemalloc_test.h"
|
||||||
|
|
||||||
#define CHUNK 0x400000
|
#define CHUNK 0x400000
|
||||||
#define MAXALIGN (((size_t)1) << 25)
|
#define MAXALIGN (((size_t)1) << 23)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* On systems which can't merge extents, tests that call this function generate
|
||||||
|
* a lot of dirty memory very quickly. Purging between cycles mitigates
|
||||||
|
* potential OOM on e.g. 32-bit Windows.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
purge(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
assert_d_eq(mallctl("arena.0.purge", NULL, NULL, NULL, 0), 0,
|
||||||
|
"Unexpected mallctl error");
|
||||||
|
}
|
||||||
|
|
||||||
TEST_BEGIN(test_alignment_errors)
|
TEST_BEGIN(test_alignment_errors)
|
||||||
{
|
{
|
||||||
@ -109,13 +122,7 @@ TEST_BEGIN(test_alignment_and_size)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
purge();
|
||||||
* On systems which can't merge extents, this test generates a
|
|
||||||
* lot of dirty memory very quickly. Purge between cycles to
|
|
||||||
* avoid potential OOM on e.g. 32-bit Windows.
|
|
||||||
*/
|
|
||||||
assert_d_eq(mallctl("arena.0.purge", NULL, NULL, NULL, 0), 0,
|
|
||||||
"Unexpected mallctl error");
|
|
||||||
}
|
}
|
||||||
#undef NITER
|
#undef NITER
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,19 @@ get_huge_size(size_t ind)
|
|||||||
return (get_size_impl("arenas.hchunk.0.size", ind));
|
return (get_size_impl("arenas.hchunk.0.size", ind));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* On systems which can't merge extents, tests that call this function generate
|
||||||
|
* a lot of dirty memory very quickly. Purging between cycles mitigates
|
||||||
|
* potential OOM on e.g. 32-bit Windows.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
purge(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
assert_d_eq(mallctl("arena.0.purge", NULL, NULL, NULL, 0), 0,
|
||||||
|
"Unexpected mallctl error");
|
||||||
|
}
|
||||||
|
|
||||||
TEST_BEGIN(test_overflow)
|
TEST_BEGIN(test_overflow)
|
||||||
{
|
{
|
||||||
size_t hugemax;
|
size_t hugemax;
|
||||||
@ -96,6 +109,7 @@ TEST_BEGIN(test_oom)
|
|||||||
if (ptrs[i] != NULL)
|
if (ptrs[i] != NULL)
|
||||||
dallocx(ptrs[i], 0);
|
dallocx(ptrs[i], 0);
|
||||||
}
|
}
|
||||||
|
purge();
|
||||||
|
|
||||||
#if LG_SIZEOF_PTR == 3
|
#if LG_SIZEOF_PTR == 3
|
||||||
assert_ptr_null(mallocx(0x8000000000000000ULL,
|
assert_ptr_null(mallocx(0x8000000000000000ULL,
|
||||||
@ -113,7 +127,7 @@ TEST_END
|
|||||||
|
|
||||||
TEST_BEGIN(test_basic)
|
TEST_BEGIN(test_basic)
|
||||||
{
|
{
|
||||||
#define MAXSZ (((size_t)1) << 26)
|
#define MAXSZ (((size_t)1) << 23)
|
||||||
size_t sz;
|
size_t sz;
|
||||||
|
|
||||||
for (sz = 1; sz < MAXSZ; sz = nallocx(sz, 0) + 1) {
|
for (sz = 1; sz < MAXSZ; sz = nallocx(sz, 0) + 1) {
|
||||||
@ -122,30 +136,28 @@ TEST_BEGIN(test_basic)
|
|||||||
nsz = nallocx(sz, 0);
|
nsz = nallocx(sz, 0);
|
||||||
assert_zu_ne(nsz, 0, "Unexpected nallocx() error");
|
assert_zu_ne(nsz, 0, "Unexpected nallocx() error");
|
||||||
p = mallocx(sz, 0);
|
p = mallocx(sz, 0);
|
||||||
assert_ptr_not_null(p, "Unexpected mallocx() error");
|
assert_ptr_not_null(p,
|
||||||
|
"Unexpected mallocx(size=%zx, flags=0) error", sz);
|
||||||
rsz = sallocx(p, 0);
|
rsz = sallocx(p, 0);
|
||||||
assert_zu_ge(rsz, sz, "Real size smaller than expected");
|
assert_zu_ge(rsz, sz, "Real size smaller than expected");
|
||||||
assert_zu_eq(nsz, rsz, "nallocx()/sallocx() size mismatch");
|
assert_zu_eq(nsz, rsz, "nallocx()/sallocx() size mismatch");
|
||||||
dallocx(p, 0);
|
dallocx(p, 0);
|
||||||
|
|
||||||
p = mallocx(sz, 0);
|
p = mallocx(sz, 0);
|
||||||
assert_ptr_not_null(p, "Unexpected mallocx() error");
|
assert_ptr_not_null(p,
|
||||||
|
"Unexpected mallocx(size=%zx, flags=0) error", sz);
|
||||||
dallocx(p, 0);
|
dallocx(p, 0);
|
||||||
|
|
||||||
nsz = nallocx(sz, MALLOCX_ZERO);
|
nsz = nallocx(sz, MALLOCX_ZERO);
|
||||||
assert_zu_ne(nsz, 0, "Unexpected nallocx() error");
|
assert_zu_ne(nsz, 0, "Unexpected nallocx() error");
|
||||||
p = mallocx(sz, MALLOCX_ZERO);
|
p = mallocx(sz, MALLOCX_ZERO);
|
||||||
assert_ptr_not_null(p, "Unexpected mallocx() error");
|
assert_ptr_not_null(p,
|
||||||
|
"Unexpected mallocx(size=%zx, flags=MALLOCX_ZERO) error",
|
||||||
|
nsz);
|
||||||
rsz = sallocx(p, 0);
|
rsz = sallocx(p, 0);
|
||||||
assert_zu_eq(nsz, rsz, "nallocx()/sallocx() rsize mismatch");
|
assert_zu_eq(nsz, rsz, "nallocx()/sallocx() rsize mismatch");
|
||||||
dallocx(p, 0);
|
dallocx(p, 0);
|
||||||
/*
|
purge();
|
||||||
* On systems which can't merge extents, this test generates a
|
|
||||||
* lot of dirty memory very quickly. Purge between cycles to
|
|
||||||
* avoid potential OOM on e.g. 32-bit Windows.
|
|
||||||
*/
|
|
||||||
assert_d_eq(mallctl("arena.0.purge", NULL, NULL, NULL, 0), 0,
|
|
||||||
"Unexpected mallctl error");
|
|
||||||
}
|
}
|
||||||
#undef MAXSZ
|
#undef MAXSZ
|
||||||
}
|
}
|
||||||
@ -153,7 +165,7 @@ TEST_END
|
|||||||
|
|
||||||
TEST_BEGIN(test_alignment_and_size)
|
TEST_BEGIN(test_alignment_and_size)
|
||||||
{
|
{
|
||||||
#define MAXALIGN (((size_t)1) << 25)
|
#define MAXALIGN (((size_t)1) << 23)
|
||||||
#define NITER 4
|
#define NITER 4
|
||||||
size_t nsz, rsz, sz, alignment, total;
|
size_t nsz, rsz, sz, alignment, total;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
@ -203,13 +215,7 @@ TEST_BEGIN(test_alignment_and_size)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
purge();
|
||||||
* On systems which can't merge extents, this test generates a
|
|
||||||
* lot of dirty memory very quickly. Purge between cycles to
|
|
||||||
* avoid potential OOM on e.g. 32-bit Windows.
|
|
||||||
*/
|
|
||||||
assert_d_eq(mallctl("arena.0.purge", NULL, NULL, NULL, 0), 0,
|
|
||||||
"Unexpected mallctl error");
|
|
||||||
}
|
}
|
||||||
#undef MAXALIGN
|
#undef MAXALIGN
|
||||||
#undef NITER
|
#undef NITER
|
||||||
|
@ -1,7 +1,20 @@
|
|||||||
#include "test/jemalloc_test.h"
|
#include "test/jemalloc_test.h"
|
||||||
|
|
||||||
#define CHUNK 0x400000
|
#define CHUNK 0x400000
|
||||||
#define MAXALIGN (((size_t)1) << 25)
|
#define MAXALIGN (((size_t)1) << 23)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* On systems which can't merge extents, tests that call this function generate
|
||||||
|
* a lot of dirty memory very quickly. Purging between cycles mitigates
|
||||||
|
* potential OOM on e.g. 32-bit Windows.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
purge(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
assert_d_eq(mallctl("arena.0.purge", NULL, NULL, NULL, 0), 0,
|
||||||
|
"Unexpected mallctl error");
|
||||||
|
}
|
||||||
|
|
||||||
TEST_BEGIN(test_alignment_errors)
|
TEST_BEGIN(test_alignment_errors)
|
||||||
{
|
{
|
||||||
@ -103,13 +116,7 @@ TEST_BEGIN(test_alignment_and_size)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
purge();
|
||||||
* On systems which can't merge extents, this test generates a
|
|
||||||
* lot of dirty memory very quickly. Purge between cycles to
|
|
||||||
* avoid potential OOM on e.g. 32-bit Windows.
|
|
||||||
*/
|
|
||||||
assert_d_eq(mallctl("arena.0.purge", NULL, NULL, NULL, 0), 0,
|
|
||||||
"Unexpected mallctl error");
|
|
||||||
}
|
}
|
||||||
#undef NITER
|
#undef NITER
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user