Skip to content

Instantly share code, notes, and snippets.

@holmeshe
Created September 20, 2018 09:09
Show Gist options
  • Select an option

  • Save holmeshe/f4c94a07e5fb7f2faef3ef9f6f66478a to your computer and use it in GitHub Desktop.

Select an option

Save holmeshe/f4c94a07e5fb7f2faef3ef9f6f66478a to your computer and use it in GitHub Desktop.
static void slabs_preallocate (const unsigned int maxslabs) {
int i;
unsigned int prealloc = 0;
/* pre-allocate a 1MB slab in every size class so people don't get
confused by non-intuitive "SERVER_ERROR out of memory"
messages. this is the most common question on the mailing
list. if you really don't want this, you can rebuild without
these three lines. */
for (i = POWER_SMALLEST /* scr: 1 */; i < MAX_NUMBER_OF_SLAB_CLASSES; i++) {
if (++prealloc > maxslabs)
return;
if (do_slabs_newslab(i) == 0) {
fprintf(stderr, "Error while preallocating slab memory!\n"
"If using -L or other prealloc options, max memory must be "
"at least %d megabytes.\n", power_largest);
exit(1);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment