Skip to content

Commit 0ef1b7b

Browse files
committed
Release RAM after indexing, static-link Windows binary
- Call cbm_mem_collect() (mi_collect(true)) after pipeline_free in both index_repository and auto-index, returning mimalloc pages to OS - Add -static to Windows linker flags so the binary is standalone (no libc++.dll / libunwind.dll dependency)
1 parent 3744c6d commit 0ef1b7b

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

Makefile.cbm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ CXXFLAGS_TSAN = $(CXXFLAGS_COMMON) -g -O1 \
7878
IS_MINGW := $(shell echo | $(CC) -dM -E - 2>/dev/null | grep -q 'define _WIN32 ' && echo yes || echo no)
7979
WIN32_LIBS :=
8080
ifeq ($(IS_MINGW),yes)
81-
WIN32_LIBS := -lws2_32 -lpsapi -Wl,--allow-multiple-definition -Wl,--stack,8388608
81+
WIN32_LIBS := -lws2_32 -lpsapi -Wl,--allow-multiple-definition -Wl,--stack,8388608 -static
8282
endif
8383

8484
LDFLAGS = -lm -lstdc++ -lpthread -lz $(LIBGIT2_LIBS) $(WIN32_LIBS)

src/mcp/mcp.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "pipeline/pipeline.h"
1414
#include "cli/cli.h"
1515
#include "watcher/watcher.h"
16+
#include "foundation/mem.h"
1617
#include "foundation/platform.h"
1718
#include "foundation/compat.h"
1819
#include "foundation/compat_fs.h"
@@ -1230,6 +1231,7 @@ static char *handle_index_repository(cbm_mcp_server_t *srv, const char *args) {
12301231
* No need to close srv->store — pipeline doesn't touch the open store. */
12311232
int rc = cbm_pipeline_run(p);
12321233
cbm_pipeline_free(p);
1234+
cbm_mem_collect(); /* return mimalloc pages to OS after large indexing */
12331235

12341236
/* Invalidate cached store so next query reopens the fresh database */
12351237
if (srv->owns_store && srv->store) {
@@ -2128,6 +2130,7 @@ static void *autoindex_thread(void *arg) {
21282130

21292131
int rc = cbm_pipeline_run(p);
21302132
cbm_pipeline_free(p);
2133+
cbm_mem_collect(); /* return mimalloc pages to OS after indexing */
21312134

21322135
if (rc == 0) {
21332136
cbm_log_info("autoindex.done", "project", srv->session_project);

0 commit comments

Comments
 (0)