BUG: gtk-text-iter allocation is completely nuts
stacksmith opened this issue · comments
Again, if I don't understand it correctly, I apologize in advance. However:
gtk-text-iter-alloc:
(defun gtk-text-iter-alloc ()
(with-foreign-object (iter '(:struct %gtk-text-iter))
(%gtk-text-iter-copy iter)))
So this creates a temporary, blank, uninitialized foreign structure %gtk-text-iter. It then calls %gtk-text-iter-copy to copy this blank, uninitialized iterator for some reason. The only remotely rational reason to do this is to allow gtk to do its own allocation using slice_alloc, etc - then we can assume that all iters can be freed using gtk-text-iter-free
- but it is not even implemented or called. And g-boxed-free is never called either, as far as I can tell.
So ok, we create this 512-byte object and free it every time an iter is alloc'd. Edit: my math is completely nuts too!
Now, since gtk-text-iters are boxed-opaque objects, and are allocated erroneously in buffer and view functions (apparently without deallocating, see #64). So every time you call gtk-text-buffer-get-iter-at-mark, for instance, a new iter created as above.
This looks like a big memory leak to me.