Menu

#627 long list creation

open
nobody
None
5
2008-03-04
2008-03-04
Anonymous
No

Hi

Creation of long strings can completely hang the system. The cause for the hanging is described as follows.

In the following simple macro

string = ""
for(i=0; i<N ; i++)
string = string "\n" i

each iteration eats memory since new string is created
and old one is also kept in memory.

When all memory is occupied a system completely hangs.

When fast-access memory (non-swap) is fully occupied,
work is strongly slowed-down, CPU usage drops to 1-10%.

Memory is not freed when macro is completed, as a result, the system goes in a "somnambular state". X-server restarting does not help in this case.

This bug is independent of NEdit's version.

Alexey Kuznetsov

Discussion

  • Tony Balinski

    Tony Balinski - 2008-05-14

    Logged In: YES
    user_id=618141
    Originator: NO

    It's actually quite easy to convert NEdit macro's mark/sweep technique so that it can run during macro execution. I have a working version of NEdit that does this. What needs to be done is to allow the mark part to run through the active macro call stacks, allowing marking of function-local strings and arrays. For this all continuation contexts need to be accessible. So it's all quite easy to do, although it's not clear how often it should be done (other than at the end of macro execution). My current implementation calls the GC after every 10000 allocations or so. A better scheme might relate amount of memory allocated and number of allocations instead, which might be better in cases such as this bug highlights.

    I have worked on a ref-counted memory management scheme, but that is rather more involved, requiring a lot of reorganising and care in programming.

    I'll make a patch when I have a moment so that others can try it.

    Tony

     
  • Nobody/Anonymous

    Logged In: NO

    Hi,

    I think, even "simple" implementation of memory checking/freeing after a macro execution/breaking and after a number of allocations can be very helpful.

    Alexey

     
  • Nobody/Anonymous

    Logged In: NO

    any fix?

     
  • Nobody/Anonymous

    Logged In: NO

    any fix?

     
  • Tony Balinski

    Tony Balinski - 2008-06-06

    Logged In: YES
    user_id=618141
    Originator: NO

    Here's the fix as described. It's not perfect, but handles much better than the current situation. (It was sent to the develop list, and commented upon: see messages starting here: http://www.nedit.org/pipermail/develop/2008-May/014533.html.\)
    File Added: ImprovedMacroGC.diff

     
  • Tony Balinski

    Tony Balinski - 2008-06-06

    Allow macro data garbage collector to run during macro execution

     
  • Nobody/Anonymous

    Logged In: NO

    Applied the patch and haven't problems so far.

    Maybe it's better to apply it to the code in CVS so that more people can have a try.

    If you have a better solution, I'd love to try!

     

Log in to post a comment.