Skip to content

Commit

Permalink
Add leak detection
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoNex committed Feb 6, 2024
1 parent afebd6d commit 303cb38
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ debug:
cd cmd/tau && \
CC=$(CC) CGO_CFLAGS="$(CFLAGS) -DDEBUG -DGC_DEBUG" CGO_LDFLAGS="$(LDFLAGS)" go build -o $(DIR)/tau

detect-leak:
cd cmd/tau && \
CC=$(CC) CGO_CFLAGS="$(CFLAGS) -DGC_DETECT_LEAK" CGO_LDFLAGS="$(LDFLAGS)" go build -o $(DIR)/tau

install: all
mv tau $(INSTALL_PATH)

Expand Down
7 changes: 6 additions & 1 deletion internal/vm/vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,12 @@ int vm_run(struct vm * restrict vm) {
return 0;
}

void gc_init(void) { GC_INIT(); }
void gc_init(void) {
GC_INIT();
#ifdef GC_DETECT_LEAK
GC_set_find_leak(1);
#endif
}

void set_exit() {
atexit(restore_term);
Expand Down

0 comments on commit 303cb38

Please sign in to comment.