Subject: sparse core dumps?
To: None <tech-kern@NetBSD.org>
From: Hubert Feyrer <hubert@feyrer.de>
List: tech-kern
Date: 06/02/2004 23:25:59
When I malloc(3) some space, it doesn't have a significant impact on the
program's memory usage, i.e. I can happily request 1GB and nothing will
happen.

But as soon as a core dump gets created, it seems that pages are allocated
just to dump them out - looking at core dump sizes indicates this.
What's really bad is that the system's performance is _really_ bad while
writing out that core dump.

To illustrate, run the program below with some different values (10000,
100000, 1000000, 10000000, ..) and look at the resulting core sizes.
Plus observe system performance during the core dump.

Would it be possible to allow core dumps to be "sparse"?


 - Hubert



#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char *argv[])
{
	long int n;
	char *p;

	sscanf(argv[1], "%ld", &n);
	printf("allocating %ld bytes\n", n);

	p = malloc(n);
	assert(p != NULL);

	abort();

	free(p);
	return 0;
}


-- 
                         ,,_
If wishes were wings,  o"   )~  would fly.            -- Go www.NetBSD.org!
                        ''''