summary refs log tree commit diff stats
path: root/tests/fragmentation/tfragment_gc.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/fragmentation/tfragment_gc.nim')
-rw-r--r--tests/fragmentation/tfragment_gc.nim30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/fragmentation/tfragment_gc.nim b/tests/fragmentation/tfragment_gc.nim
new file mode 100644
index 000000000..1781f6610
--- /dev/null
+++ b/tests/fragmentation/tfragment_gc.nim
@@ -0,0 +1,30 @@
+discard """
+  output: '''occupied ok: true
+total ok: true'''
+"""
+
+import strutils, data
+
+proc main =
+  var m = 0
+  # Since the GC test is slower than the alloc test, we only iterate 100_000 times here:
+  for i in 0..100_000:
+    let size = sizes[i mod sizes.len]
+    let p = newString(size)
+ #   c_fprintf(stdout, "iteration: %ld size: %ld\n", i, size)
+
+main()
+
+let occ = getOccupiedMem()
+let total = getTotalMem()
+
+# Concrete values on Win64: 58.152MiB / 188.285MiB
+
+let occupiedOk = occ < 64 * 1024 * 1024
+if not occupiedOk:
+  echo "occupied ", formatSize(occ)
+echo "occupied ok: ", occupiedOk
+let totalOk = total < 210 * 1024 * 1024
+if not totalOk:
+  echo "total peak memory ", formatSize(total)
+echo "total ok: ", totalOk