Fuco1 / justify-kp

Paragraph justification for emacs using Knuth/Plass algorithm
55 stars 7 forks source link

Memory exhausted--use C-x s then exit and restart Emacs #5

Closed wasamasa closed 7 months ago

wasamasa commented 7 years ago

I get this when rendering the first chapter of Mastering Emacs with Cambria at a font size greater than 17. Reducing the font size makes Emacs proceed normally. I've always assumed the algorithm to be problematic with regards to runtime, not memory usage. Any ideas how I can debug this?

Fuco1 commented 7 years ago

Runtime is rather finely bound at O(n^2), probably O(n^3) with the silly data structures we have in lisp (linked lists). I don't really store the memory most optimally (if you print it out you can get an exponential serialization), but I think that emacs does some structure sharing internally so it too should be at most quadratic (in short, each possible line stores the reference to all parents who store references to all parents...). I don't really know how to debug this though.

wasamasa commented 7 years ago

Alright, what you could do is measuring memory usage after each call of the function and see whether it correlates to the error message. That's it for my ideas though, other than doing a rewrite with vectors.

Fuco1 commented 7 months ago

I'm going to close this and investigate more if there will be issues. I rewrote the algorithm since then I think :D