From 444e59829ae4bd888099bc96277f606d531f3828 Mon Sep 17 00:00:00 2001
From: Konstantin Osipov <kostja@tarantool.org>
Date: Wed, 3 Apr 2013 14:56:50 +0400
Subject: [PATCH] Fix bug https://bugs.launchpad.net/tarantool/+bug/1163858

Replication relay was created (forked) after initialization
of slab allocator, and, consequently, had a very large address
space. The memory wasn't used really.

Initialize slab allocator after creation of a replication
relay process.

No test case since we don't have automation to detect that sort
of problems.
---
 src/tarantool.m | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/src/tarantool.m b/src/tarantool.m
index 869a0dac1a..8163ac63cb 100644
--- a/src/tarantool.m
+++ b/src/tarantool.m
@@ -606,19 +606,13 @@ tarantool_free(void)
 }
 
 static void
-initialize(double slab_alloc_arena, int slab_alloc_minimal, double slab_alloc_factor)
+initialize_minimal()
 {
-	if (!salloc_init(slab_alloc_arena * (1 << 30), slab_alloc_minimal, slab_alloc_factor))
+	if (!salloc_init(64 * 1000 * 1000, 4, 2))
 		panic_syserror("can't initialize slab allocator");
 	fiber_init();
 }
 
-static void
-initialize_minimal()
-{
-	initialize(0.1, 4, 2);
-}
-
 int
 main(int argc, char **argv)
 {
@@ -859,8 +853,10 @@ main(int argc, char **argv)
 	atexit(tarantool_free);
 
 	ev_default_loop(EVFLAG_AUTO);
-	initialize(cfg.slab_alloc_arena, cfg.slab_alloc_minimal, cfg.slab_alloc_factor);
+	fiber_init();
 	replication_prefork();
+	salloc_init(cfg.slab_alloc_arena * (1 << 30) /* GB */,
+		    cfg.slab_alloc_minimal, cfg.slab_alloc_factor);
 
 	signal_init();
 
-- 
GitLab