v2 / vlib / v / tests / testcase_leak.vv
13 lines · 12 sloc · 339 bytes · 32462004e66ca5f5201dc5b816ba4151e7e8c6d5
Raw
1// This program is supposed to test the leak detector which
2// is integrated with `-gc boehm_leak` at compile time.
3//
4// If compiled with `-gc boehm` or without `-gc` nothing
5// will be reported.
6
7fn main() {
8 mut y := unsafe { malloc(1000) }
9 // unsafe { free(y) } // leak if commented out
10 y = unsafe { nil }
11 _ = y
12 gc_check_leaks()
13}
14