From 7327adbc86eb3c1ded3027cb93c93c1a7427bb25 Mon Sep 17 00:00:00 2001
From: Aliaksandr Valialkin <valyala@gmail.com>
Date: Fri, 17 Jan 2020 16:27:16 +0200
Subject: [PATCH] app/vmselect/netstorage: limit the maximum size for in-memory
 buffer for temporary blocks file

This should reduce memory usage on systems with more than 8GB RAM.
---
 app/vmselect/netstorage/tmp_blocks_file.go | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/app/vmselect/netstorage/tmp_blocks_file.go b/app/vmselect/netstorage/tmp_blocks_file.go
index 3667d12b43..9f6f072ed3 100644
--- a/app/vmselect/netstorage/tmp_blocks_file.go
+++ b/app/vmselect/netstorage/tmp_blocks_file.go
@@ -36,6 +36,9 @@ func maxInmemoryTmpBlocksFile() int {
 	if maxLen < 64*1024 {
 		return 64 * 1024
 	}
+	if maxLen > 4*1024*1024 {
+		return 4*1024*1024
+	}
 	return maxLen
 }