Not Enough Memory trap - is it normal behaviour?

Started by IVShilov, April 06, 2019, 01:59:06 AM

Previous topic - Next topic

IVShilov

Trying to understand how dump work on variable which not set
newLISP v.10.7.1 32-bit on Windows IPv4/6 UTF-8 libffi, options: newlisp -h
# (WindowsXP)
> (setq R '()) (time (push (dump x) R -1) 10 )(map unique (transpose R))
((5249584) (256) (5243024) (5243024) (5243024))


I get in such odd situation: RAM exhausted, error occurs, but no RAM was released and REPL still works.

See:
(setq R '()) (time (push (dump x) R -1) 100000000 ) (map unique (transpose R))
()

ERR: not enough memory in function dump
> (delete 'x) # more than minute for evaluation
true
> # still 2Gb RAM
> (reset)
> # no effect
> (symbols)

ERR: not enough memory in function symbols
> (dotree (s MAIN) (delete s true))

ERR: not enough memory
> (sys-info)

ERR: not enough memory
> (delete 'x) # try again

ERR: not enough memory
> (exit)

ERR: not enough memory

Nothing helps and I have to kill process.

Bug or a feature?

I mean is it points to some newlisp lack or I must be more careful with all memory-related functions?



UPD:

This crash test is reproductible:
> (setq R '()) (time (push (dump x) R -1) 100000000 ) (map unique (transpose R))
()

ERR: not enough memory in function dump
> (delete 'R) (reset)

 - memory released and came back to normal values,

but repeat
> (setq R '()) (time (push (dump x) R -1) 100000000 ) (map unique (transpose R))
lead to endless "ERR: not enough memory", 2Gb RAM and 50% CPU owned by newlisp.exe, and nothing helps except kill process.