Thanks Po! Indeed, I was not aware of that (I couldn't find anywhere what vscroll means 'exactly',
i.e. I did not know it was 'relative w.r.t. the 'current point').
Anyway, indeed doing what you suggested works great (i.e. fast scrolling and no issue with the
large memory). Too bad I have to rewrite substantial parts of image-roll.el again, but after that I
think it will finally provide a quite nice 'image-roll'.

On Tue, 26 Apr 2022 at 14:49, Po Lu <luangruo@yahoo.com> wrote:
dalanicolai <dalanicolai@gmail.com> writes:

> So I have created `image-roll.el` for displaying documents/books (see
> here).  However, I have just noticed that it uses a large amount of
> RAM when viewing (or trying to) pages in the back of 'large'
> books. But even if RAM usage still looks perfectly fine, Emacs crashes
> when trying to scroll to higher page numbers.

I didn't try to reproduce this problem, but note that it's slow to
vscroll large amounts of text.  Instead, find the start of the first
line that will be visible onscreen (using window-text-pixel-size or
posn-at-point), make that the window start, and set vscroll starting
from there instead.