BUG/MEDIUM: state-file: do not allocate a full buffer for each server entry
authorWilly Tarreau <w@1wt.eu>
Fri, 20 Dec 2019 16:18:13 +0000 (17:18 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 20 Dec 2019 16:35:34 +0000 (17:35 +0100)
commite15cf47c00df06c3a37da4ff5dfc84732f174bb3
tree0603ef71632e96e1ea44212ffba9c678dd2b36f2
parentd0f06ab5f1f99049e17445f265d2613c01129599
BUG/MEDIUM: state-file: do not allocate a full buffer for each server entry

Starting haproxy with a state file of 700k servers eats 11.2 GB of RAM
due to a mistake in the function that loads the strings into a tree: it
allocates a full buffer for each backend+server name instead of allocating
just the required string. By just fixing this we're down to 80 MB.

This should be backported to 2.1.

(cherry picked from commit 7d6a1fa311312bb99b98f548399fc30fc7802ad7)
Signed-off-by: Willy Tarreau <w@1wt.eu>
src/server.c