summary refs log tree commit diff stats
path: root/tests/gc/growobjcrash.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/gc/growobjcrash.nim')
-rw-r--r--tests/gc/growobjcrash.nim24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/gc/growobjcrash.nim b/tests/gc/growobjcrash.nim
new file mode 100644
index 000000000..ff1aa7e98
--- /dev/null
+++ b/tests/gc/growobjcrash.nim
@@ -0,0 +1,24 @@
+import std/[cgi, strtabs]
+
+proc handleRequest(query: string): StringTableRef =
+  iterator foo(): StringTableRef {.closure.} =
+    var params = {:}.newStringTable()
+    for key, val in cgi.decodeData(query):
+      params[key] = val
+    yield params
+
+  let x = foo
+  result = x()
+
+const Limit = 5*1024*1024
+
+proc main =
+  var counter = 0
+  for i in 0 .. 10_000:
+    for k, v in handleRequest("nick=Elina2&type=activate"):
+      inc counter
+      if counter mod 100 == 0:
+        if getOccupiedMem() > Limit:
+          quit "but now a leak"
+
+main()