metaeducation / rebol-issues

6 stars 1 forks source link

GC doesn't recycle unused memory after "not enough memory" error when needed #1889

Open rebolbot opened 13 years ago

rebolbot commented 13 years ago

Submitted by: cyphre2

When a REBOL script alocates all available memory and "not enough memory" error! is triggered(and properly caught using TRY) any subsequent memory allocation is not possible without calling RECYCLE explicitly. The already allocated memory before the error is not returned for later rebol code usage. See example below...

recycle
stats-init: stats
blocks: copy []
if error? try [
    n: 0
    forever [
        append/only blocks make block! 1000000
        print [++ n stats]
    ]
][
    print "not enough memory, recycling..."
    clear blocks
;   Without the following recycle call it is not possible to get the allocated memory back.
;   recycle
    print "recycling done"
    print [stats-init s: stats stats-init - s]
;   let's try to allocate some mem again - no luck without the explicit RECYCLE though
    b: make block! 1000000 
]

CC - Data [ Version: alpha 112 Type: Bug Platform: All Category: Documentation Reproduce: Always Fixed-in:none ]

rebolbot commented 13 years ago

Submitted by: Ladislav

The same problem is observed/observable in R2 as well.

rebolbot commented 11 years ago

Submitted by: Ladislav

It looks that the optimal solution to this problem is just a good documentation mentioning how to handle such situations.