Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#490 Concatenation in macro seems not to release used memory

open
nobody
Program (402)
5
2005-10-04
2005-10-04
Anonymous
No

Following macro code can cause the computer to hang up
by not releasing used memory:

define waste_mem{
for (i=0; i<10000; i++){
t=""
for (j=0; j<10000; j++){
t = t " "
}
}
}

It seems that in each loop the result of the
concatenation is copied to the memory but the old
memory range is not released.

Discussion

  • Tony Balinski
    Tony Balinski
    2005-10-04

    Logged In: YES
    user_id=618141

    That's right. It's a limitation of the way macro string
    memory is managed. Essentially, macro memory is only freed
    once there are no more running macros. For short macros this
    is not a problem. For larger ones (particularly where lots
    of small bits are accumulated into a big string) it can
    cause severe memory shortages. I have detab/retab macros
    which suffer from this.

    I got about 2/3 of the way to replacing the macro string
    memory management, rewriting a lot of interpret.c and
    macro.c. I should brush the dust off it and get it all to work!