growobjcrash.nim 645 B

123456789101112131415161718192021222324252627282930
  1. discard """
  2. output: "works"
  3. """
  4. import cgi, strtabs
  5. proc handleRequest(query: string): StringTableRef =
  6. iterator foo(): StringTableRef {.closure.} =
  7. var params = {:}.newStringTable()
  8. for key, val in cgi.decodeData(query):
  9. params[key] = val
  10. yield params
  11. let x = foo
  12. result = x()
  13. const Limit = when compileOption("gc", "markAndSweep"): 5*1024*1024 else: 700_000
  14. proc main =
  15. var counter = 0
  16. for i in 0 .. 100_000:
  17. for k, v in handleRequest("nick=Elina2&type=activate"):
  18. inc counter
  19. if counter mod 100 == 0:
  20. if getOccupiedMem() > Limit:
  21. quit "but now a leak"
  22. main()
  23. echo "works"