How to measure memory consumption of DXL script? -


finding out if script has significant memory leak might of interest before run serious trouble. unfortunately, not able find out how measure current stack/heap size or "string table" size (see http://www.smartdxl.com/content/?p=481). can help?

related question: predicting dxl memory , cpu usage

the biggest memory "leak" open modules no longer being used. of course should closing those.

next want keep production of new strings minimum since each new 1 creates entry in string table. can find excellent dissertation on mathias mamsch here: https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014886977&ps=25

finally, data types have create/delete methods can eat memory if not being deleted. find unreleased instances, use memory functions created mathias mamsch. link have post no longer works, here functions use:

//< memory functions [memory.inc] /* code adapted forum post mathias mamsch: https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014830975 */  int *::+(int *ptr, int ofs) {     int *rtn = ptr     rtn += ofs     return(rtn) }  int *::@(int *ptr, int ofs) {     int adr = *(ptr + ofs)     int *rtn = addr_(adr)     return(rtn) }  int *mbn(int *ptr) {     return(ptr @ 0x74) }  int *nnn(int *ptr) {     return(ptr @ 8) }  int *ccp() {     db db = create("")     int *ptr = addr_(db)     int *rtn = ptr @ 48     destroy(db)     return(rtn) }  int allocatedobjects() {     int cnt = 0     int *mb = mbn(ccp())     while(!null mb) { mb = nnn(mb) ; cnt++ }     return(cnt) } 

i'm pretty sure changed function , variable names original posted code, aware of if ever come across original code. , don't ask me hard-coded numbers... mathias explained them in post , don't recall explanation.

here's how use code:

//< test of memory.inc /* */ pragma encoding, "utf-8"  #include <stdlib/memory.inc>  pragma runlim, 0  int numallobj = allocatedobjects() print numallobj "\n"  skip skp = null skip  numallobj = allocatedobjects() print numallobj "\n"  skp = create()  numallobj = allocatedobjects() print numallobj "\n"  delete(skp)  numallobj = allocatedobjects() print numallobj "\n"  /* output should be: 0 0 1 0 */ 

Comments