Last active
August 29, 2015 14:02
-
-
Save Alloyed/f1302f90e5e9c73fed5d to your computer and use it in GitHub Desktop.
memory usage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ nodejs --version && lua -v && luajit -v | |
| v0.10.28 | |
| Lua 5.2.3 Copyright (C) 1994-2013 Lua.org, PUC-Rio | |
| LuaJIT 2.0.3 -- Copyright (C) 2005-2014 Mike Pall. http://luajit.org/ | |
| $ nodejs --expose-gc test.js && lua test.lua && luajit test.lua | |
| ---- | |
| nodejs | |
| ---- | |
| 1804856 | |
| 255285256 | |
| 177807656 | |
| --- | |
| lua | |
| --- | |
| 24214 | |
| 100687638 | |
| 16799614 | |
| --- | |
| luajit | |
| --- | |
| 28069 | |
| 58749005 | |
| 4221265 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| console.log("----"); | |
| console.log(process.argv[0]); | |
| console.log("----"); | |
| global.gc(); | |
| console.log(process.memoryUsage().heapUsed); | |
| var BIGNUM = Math.pow(2,20); | |
| var a = []; | |
| var b = {}; | |
| for (_i = 0; _i < BIGNUM; ++_i) { | |
| (function(i) { | |
| a[i] = function(v) { | |
| return { v : i } | |
| } | |
| }(_i)); | |
| } | |
| global.gc(); | |
| console.log(process.memoryUsage().heapUsed); | |
| for (i = 0; i < BIGNUM; ++i) { | |
| var key = "KEYOF" + i; | |
| var tmp = a[i](key); | |
| b[key] = tmp[key]; | |
| } | |
| a = undefined; | |
| global.gc(); | |
| console.log(process.memoryUsage().heapUsed); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| print("---") | |
| print(arg[-1]) | |
| print("---") | |
| collectgarbage 'collect' | |
| print(1024 * collectgarbage 'count') | |
| local BIGNUM = math.pow(2,20) | |
| local a, b = {}, {} | |
| for i=1, BIGNUM do | |
| a[i] = function(v) | |
| return { v = i } | |
| end | |
| end | |
| collectgarbage 'collect' | |
| print(1024 * collectgarbage 'count') | |
| for i, f in ipairs(a) do | |
| local key = "KEYOF" .. tostring(i) | |
| local tmp = f(key) | |
| b[key] = tmp[key] | |
| end | |
| a = nil | |
| collectgarbage 'collect' | |
| print(1024 * collectgarbage 'count') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment