Comparison

util-src/pposix.c @ 4950:02e5e9fa37b8

util.pposix: Add comments to mallinfo fields we use, so I don't forget tomorrow what they mean
author Matthew Wild <mwild1@gmail.com>
date Sun, 08 Jul 2012 18:54:30 +0100
parent 4946:2975c7008ccd
child 5044:4ef0dbfead53
comparison
equal deleted inserted replaced
4948:2c1de519f639 4950:02e5e9fa37b8
620 #ifdef WITH_MALLINFO 620 #ifdef WITH_MALLINFO
621 int lc_meminfo(lua_State* L) 621 int lc_meminfo(lua_State* L)
622 { 622 {
623 struct mallinfo info = mallinfo(); 623 struct mallinfo info = mallinfo();
624 lua_newtable(L); 624 lua_newtable(L);
625 /* This is the total size of memory allocated with sbrk by malloc, in bytes. */
625 lua_pushinteger(L, info.arena); 626 lua_pushinteger(L, info.arena);
626 lua_setfield(L, -2, "allocated"); 627 lua_setfield(L, -2, "allocated");
628 /* This is the total size of memory allocated with mmap, in bytes. */
627 lua_pushinteger(L, info.hblkhd); 629 lua_pushinteger(L, info.hblkhd);
628 lua_setfield(L, -2, "allocated_mmap"); 630 lua_setfield(L, -2, "allocated_mmap");
631 /* This is the total size of memory occupied by chunks handed out by malloc. */
629 lua_pushinteger(L, info.uordblks); 632 lua_pushinteger(L, info.uordblks);
630 lua_setfield(L, -2, "used"); 633 lua_setfield(L, -2, "used");
634 /* This is the total size of memory occupied by free (not in use) chunks. */
631 lua_pushinteger(L, info.fordblks); 635 lua_pushinteger(L, info.fordblks);
632 lua_setfield(L, -2, "unused"); 636 lua_setfield(L, -2, "unused");
637 /* This is the size of the top-most releasable chunk that normally borders the
638 end of the heap (i.e., the high end of the virtual address space's data segment). */
633 lua_pushinteger(L, info.keepcost); 639 lua_pushinteger(L, info.keepcost);
634 lua_setfield(L, -2, "returnable"); 640 lua_setfield(L, -2, "returnable");
635 return 1; 641 return 1;
636 } 642 }
637 #endif 643 #endif