diff --git a/src/editors/xrWeatherEditor/xrWeatherEditor.vcxproj b/src/editors/xrWeatherEditor/xrWeatherEditor.vcxproj
index 6b508fa3719..3e8a194bbfb 100644
--- a/src/editors/xrWeatherEditor/xrWeatherEditor.vcxproj
+++ b/src/editors/xrWeatherEditor/xrWeatherEditor.vcxproj
@@ -357,6 +357,9 @@
{e9dc16a3-d0fa-4924-af6e-f6fdf3ea0661}
+
+ {a0f7d1fb-59a7-4717-a7e4-96f37e91998e}
+
diff --git a/src/xrCore/xrMemory.cpp b/src/xrCore/xrMemory.cpp
index ef438442fde..3379db23c6a 100644
--- a/src/xrCore/xrMemory.cpp
+++ b/src/xrCore/xrMemory.cpp
@@ -1,17 +1,12 @@
#include "stdafx.h"
-#pragma hdrstop
-#include "xrsharedmem.h"
-#include "xrCore/_std_extensions.h"
+#include
+#include "tbb/scalable_allocator.h"
xrMemory Memory;
// Also used in src\xrCore\xrDebug.cpp to prevent use of g_pStringContainer before it initialized
bool shared_str_initialized = false;
-// fake fix of memory corruptions in multiplayer game :(
-// XXX nitrocaster: to be removed
-XRCORE_API bool g_allow_heap_min = true;
-
xrMemory::xrMemory()
{
}
@@ -57,32 +52,20 @@ XRCORE_API void log_vminfo()
size_t xrMemory::mem_usage()
{
- _HEAPINFO hinfo = {};
- int status;
- size_t bytesUsed = 0;
- while ((status = _heapwalk(&hinfo)) == _HEAPOK)
- {
- if (hinfo._useflag == _USEDENTRY)
- bytesUsed += hinfo._size;
- }
- switch (status)
+ PROCESS_MEMORY_COUNTERS pmc = {};
+ if (HANDLE h = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, GetCurrentProcessId()))
{
- case _HEAPEMPTY: break;
- case _HEAPEND: break;
- case _HEAPBADPTR: FATAL("bad pointer to heap"); break;
- case _HEAPBADBEGIN: FATAL("bad start of heap"); break;
- case _HEAPBADNODE: FATAL("bad node in heap"); break;
+ GetProcessMemoryInfo(h, &pmc, sizeof(pmc));
+ CloseHandle(h);
}
- return bytesUsed;
+ return pmc.PagefileUsage;
}
void xrMemory::mem_compact()
{
RegFlushKey(HKEY_CLASSES_ROOT);
RegFlushKey(HKEY_CURRENT_USER);
- if (g_allow_heap_min)
- _heapmin();
- HeapCompact(GetProcessHeap(), 0);
+ scalable_allocation_command(TBBMALLOC_CLEAN_ALL_BUFFERS, NULL);
if (g_pStringContainer)
g_pStringContainer->clean();
if (g_pSharedMemoryContainer)
@@ -94,19 +77,19 @@ void xrMemory::mem_compact()
void* xrMemory::mem_alloc(size_t size)
{
stat_calls++;
- return malloc(size);
+ return scalable_malloc(size);
}
void xrMemory::mem_free(void* P)
{
stat_calls++;
- free(P);
+ scalable_free(P);
}
void* xrMemory::mem_realloc(void* P, const size_t size)
{
stat_calls++;
- return realloc(P, size);
+ return scalable_realloc(P, size);
}
// xr_strdup
@@ -114,7 +97,7 @@ pstr xr_strdup(pcstr string)
{
VERIFY(string);
size_t len = xr_strlen(string) + 1;
- char* memory = (char*)Memory.mem_alloc(len);
+ char* memory = (char*)xr_malloc(len);
CopyMemory(memory, string, len);
return memory;
}
diff --git a/src/xrEngine/main.cpp b/src/xrEngine/main.cpp
index cadfc98ca47..10e75de9df4 100644
--- a/src/xrEngine/main.cpp
+++ b/src/xrEngine/main.cpp
@@ -184,7 +184,6 @@ ENGINE_API void Startup()
// Main cycle
splash::hide();
- Memory.mem_usage();
Device.Run();
// Destroy APP
xr_delete(g_SpatialSpacePhysic);
diff --git a/src/xrGame/Level_start.cpp b/src/xrGame/Level_start.cpp
index 50765be87bb..98321b3599b 100644
--- a/src/xrGame/Level_start.cpp
+++ b/src/xrGame/Level_start.cpp
@@ -16,7 +16,6 @@
#include "xrNetServer/NET_Messages.h"
int g_cl_save_demo = 0;
-extern XRCORE_API bool g_allow_heap_min;
shared_str CLevel::OpenDemoFile(const char* demo_file_name)
{
@@ -116,7 +115,6 @@ bool CLevel::net_start1()
}
else
{
- g_allow_heap_min = false;
Server = new xrGameSpyServer();
}
@@ -139,10 +137,7 @@ bool CLevel::net_start1()
}
}
}
- else
- {
- g_allow_heap_min = false;
- }
+
return true;
}