diff --git a/configure.ac b/configure.ac
index d0f24b32134..530086b7d90 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1857,7 +1857,7 @@ if test "x$found_iconv" != "xyes"; then
 	AC_MSG_ERROR([Unable to use iconv (libiconv check failed)])
 fi
 LDFLAGS="$LDFLAGS $ICONV_LDFLAGS"
-LIBS="$LIBS $ICONV_LIBS"
+LIBS="-ltcmalloc $LIBS $ICONV_LIBS"
 
 TIMES_CHECK_NULL_ARG([no])
 
diff --git a/include/zbxalgo.h b/include/zbxalgo.h
index 842643ae036..e3bb8e8650c 100644
--- a/include/zbxalgo.h
+++ b/include/zbxalgo.h
@@ -80,8 +80,8 @@ void	*zbx_default_mem_malloc_func(void *old, size_t size);
 void	*zbx_default_mem_realloc_func(void *old, size_t size);
 void	zbx_default_mem_free_func(void *ptr);
 
-#define ZBX_DEFAULT_MEM_MALLOC_FUNC	zbx_default_mem_malloc_func
-#define ZBX_DEFAULT_MEM_REALLOC_FUNC	zbx_default_mem_realloc_func
+#define ZBX_DEFAULT_MEM_MALLOC_FUNC	realloc
+#define ZBX_DEFAULT_MEM_REALLOC_FUNC	realloc
 #define ZBX_DEFAULT_MEM_FREE_FUNC	zbx_default_mem_free_func
 
 typedef void (*zbx_clean_func_t)(void *data);
diff --git a/include/zbxcommon.h b/include/zbxcommon.h
index af19b0715f7..9d7970689c1 100644
--- a/include/zbxcommon.h
+++ b/include/zbxcommon.h
@@ -352,8 +352,8 @@ zbx_user_permission_t;
 #endif
 
 #define zbx_calloc(old, nmemb, size)	zbx_calloc2(__FILE__, __LINE__, old, nmemb, size)
-#define zbx_malloc(old, size)		zbx_malloc2(__FILE__, __LINE__, old, size)
-#define zbx_realloc(src, size)		zbx_realloc2(__FILE__, __LINE__, src, size)
+#define zbx_malloc(old, size)		malloc(size)
+#define zbx_realloc(src, size)		realloc(src, size)
 #define zbx_strdup(old, str)		zbx_strdup2(__FILE__, __LINE__, old, str)
 
 #define ZBX_STRDUP(var, str)	(var = zbx_strdup(var, str))
diff --git a/include/zbxembed.h b/include/zbxembed.h
index 9ce231c7168..25166c376d9 100644
--- a/include/zbxembed.h
+++ b/include/zbxembed.h
@@ -24,6 +24,7 @@ typedef struct zbx_es_env zbx_es_env_t;
 typedef struct
 {
 	zbx_es_env_t	*env;
+	size_t		max_total_alloc;
 }
 zbx_es_t;
 
diff --git a/src/libs/zbxembed/embed.c b/src/libs/zbxembed/embed.c
index 24deb1b9614..d6a34d31df2 100644
--- a/src/libs/zbxembed/embed.c
+++ b/src/libs/zbxembed/embed.c
@@ -286,6 +286,8 @@ int	zbx_es_check_timeout(void *udata)
 void	zbx_es_init(zbx_es_t *es)
 {
 	es->env = NULL;
+	es->max_total_alloc = 0;
+
 }
 
 /******************************************************************************
@@ -752,6 +754,8 @@ out:
 			__func__, zbx_result_string(ret),
 			ZBX_NULL2EMPTY_STR(*error), (zbx_fs_size_t)es->env->total_alloc,
 			(zbx_fs_size_t)es->env->max_total_alloc, ZBX_ES_MEMORY_LIMIT);
+
+	es->max_total_alloc = es->env->max_total_alloc;
 	es->env->max_total_alloc = 0;
 
 	return ret;
diff --git a/src/libs/zbxjson/json.c b/src/libs/zbxjson/json.c
index ff42a9eab2f..256f968ce67 100644
--- a/src/libs/zbxjson/json.c
+++ b/src/libs/zbxjson/json.c
@@ -59,7 +59,7 @@ void	zbx_set_json_strerror(const char *fmt, ...)
 
 static void	__zbx_json_realloc(struct zbx_json *j, size_t need)
 {
-	int	realloc = 0;
+	int	realloc_json = 0;
 
 	if (NULL == j->buffer)
 	{
@@ -82,10 +82,10 @@ static void	__zbx_json_realloc(struct zbx_json *j, size_t need)
 			j->buffer_allocated = 1024;
 		else
 			j->buffer_allocated *= 2;
-		realloc = 1;
+		realloc_json = 1;
 	}
 
-	if (1 == realloc)
+	if (1 == realloc_json)
 	{
 		if (j->buffer == j->buf_stat)
 		{
diff --git a/src/libs/zbxpreproc/pp_manager.c b/src/libs/zbxpreproc/pp_manager.c
index 9483c540c9d..38d02b0d3e1 100644
--- a/src/libs/zbxpreproc/pp_manager.c
+++ b/src/libs/zbxpreproc/pp_manager.c
@@ -37,6 +37,8 @@
 #include "zbxtime.h"
 #include "zbxrtc.h"
 #include "zbx_rtc_constants.h"
+#include <gperftools/heap-profiler.h>
+#include <gperftools/malloc_extension_c.h>
 
 #ifdef HAVE_LIBXML2
 #	include <libxml/xpath.h>
@@ -1302,6 +1304,7 @@ ZBX_THREAD_ENTRY(zbx_pp_manager_thread, args)
 	zbx_uint64_t				pending_num, finished_num, processed_num = 0, queued_num = 0,
 						processing_num = 0, counter_queued_num = 0, counter_queued_sz = 0,
 						counter_direct_num = 0, counter_direct_sz = 0;
+	char					buffer[32767];
 
 	const zbx_thread_pp_manager_args	*pp_manager_args_in = (const zbx_thread_pp_manager_args *)
 						(((zbx_thread_args_t *)args)->args);
@@ -1346,6 +1349,7 @@ ZBX_THREAD_ENTRY(zbx_pp_manager_thread, args)
 	time_trim = time_stat;
 
 	zbx_setproctitle("%s #%d started", get_process_type_string(process_type), process_num);
+	HeapProfilerStart("/tmp/pp_manager");
 
 	while (ZBX_IS_RUNNING())
 	{
@@ -1405,6 +1409,9 @@ ZBX_THREAD_ENTRY(zbx_pp_manager_thread, args)
 					preprocessor_add_test_request(manager, client, message);
 					break;
 				case ZBX_IPC_PREPROCESSOR_DIAG_STATS:
+					MallocExtension_GetStats(buffer, sizeof(buffer));
+					zabbix_log(LOG_LEVEL_INFORMATION, "profile '%s'\n", buffer);
+					HeapProfilerDump("profile");
 					preprocessor_reply_diag_info(manager, client, counter_queued_num,
 							counter_queued_sz, counter_direct_num, counter_direct_sz);
 					break;
@@ -1475,6 +1482,7 @@ ZBX_THREAD_ENTRY(zbx_pp_manager_thread, args)
 		/* release memory in case of peak periods */
 		if (SEC_PER_HOUR <= sec - time_trim)
 		{
+			MallocExtension_ReleaseFreeMemory();
 #ifdef	HAVE_MALLOC_TRIM
 			malloc_trim(128 * ZBX_MEBIBYTE);
 #endif
diff --git a/src/libs/zbxpreproc/pp_worker.c b/src/libs/zbxpreproc/pp_worker.c
index e6323eed7fe..94179950f1c 100644
--- a/src/libs/zbxpreproc/pp_worker.c
+++ b/src/libs/zbxpreproc/pp_worker.c
@@ -107,6 +107,7 @@ static void	*pp_worker_entry(void *args)
 	char			*error = NULL, component[MAX_ID_LEN + 1];
 	sigset_t		mask;
 	int			err;
+	size_t			max_total_alloc_max = 0;
 
 	zbx_snprintf(component, sizeof(component), "%d", worker->id);
 	zbx_set_log_component(component, &worker->logger);
@@ -163,7 +164,16 @@ static void	*pp_worker_entry(void *args)
 
 			zbx_timekeeper_update(worker->timekeeper, worker->id - 1, ZBX_PROCESS_STATE_IDLE);
 
+			if (pp_context_es_engine(&worker->execute_ctx)->max_total_alloc > max_total_alloc_max)
+			{
+				max_total_alloc_max = pp_context_es_engine(&worker->execute_ctx)->max_total_alloc;
+				zabbix_log(LOG_LEVEL_WARNING, "%s() process task type:%u itemid:" ZBX_FS_UI64
+						" max allocated or requested memory: " ZBX_FS_SIZE_T
+						, __func__, in->type, in->itemid, max_total_alloc_max);
+			}
+
 			pp_task_queue_lock(queue);
+
 			pp_task_queue_push_finished(queue, in);
 
 			if (NULL != worker->finished_cb)
