replace with empty pattern crashes and eats up memory

Started by HPW, December 03, 2003, 01:26:46 PM

Previous topic - Next topic

HPW

In newlisp 7.314:

(set 'str "ZZZZZxZZZZyy")
(replace "[x|y]" str "PP" 0)
"ZZZZZPPZZZZPPPP"

(replace "" str "PP" 0)


Empty replace pattern crashes heavily by eating up memory from newlisp.exe. I entered it accidently on testing the DLL.
Hans-Peter

HPW

#1
This should be checked, because neobook users can do this often accidently. In neobook the [] (brackets) mark a neobook variable and in this case they are replaced with a empty string. neobook user have to use [#91] and [#93] instead.
Hans-Peter

Lutz

#2
this will be fixed in 7.3.15 today



Lutz

nigelbrown

#3
Just to follow up on the memory eating behaviour,

would it be possible (in a future release) to have a command line

switch to set a limit on memory use and then give an out of memory

error - rather than trying to consume all of available windows memory?

Sometimes you 'know' any heavy memory use will be a programming

error that you would like to be able to (reset from.

In windows if newlisp grows the swap file to consume all swap space

then windows itself or explorer etc have problems and recovering the system

needs a reboot. To protect one from this windows feature

could we limit total (or subcategory) memory use.



I did a (sequence 2 averybignumber) and my win98 fell to bits.



Regards

Nigel

Lutz

#4
a memory check may be be an expensive thing to implement? One line of code but degrading speed, because it is one of the routines newLISP is calling all the time. But you could check the cell count in a function suspect for potential memory overuse with 'sys-info'. There are also other ways to control memory usage i.e. with memory quotas in Unix systems.



Lutz

nigelbrown

#5
I was wondering (I've not looked at the code yet - sorry a bit lazy of me) if newlisp had a point where occasionally it requested another chunk of memory from windows to put aside as its own free space - then a memory check could be made at those occasional heap growing requests.

Nigel

Lutz

#6
Yes, there is a allocBlock() for a 1000 cells. Of course  that would only handle cell memory (the biggest memory portion in most cases), it would not cover string allocations.



Perhaps for 8.0 I do the cell limit.



Lutz

nigelbrown

#7
Hi Lutz

Thank you for adding the -m N memory limiting switch to 7.4.1 in the development stream.

I've tried it with

(define (usemem n)(dotimes (x n) (set (symbol (string "nnn" x)) (sequence 1 1000))))

and newlisp stops very gracefully.



Could you make the memory restriction limit available via (sys-info) so that a program could potentially take action if the memory limit was approaching or so it could check prior to a memory intensive action?

(I realise that newlisp can't say that the memory will actually be available from the system)



Nigel