Skip to content

Memory "leak" in TclTk #88

Open
Open

Description

@Ant1r

pdlua graphics feature is fantastic.

However, too bad, it consumes quite a lot of memory each time a redraw happens.

This can be tested with the following setup:
pdlua-leak.zip

Image

I'd say that each fill_rect eats about 128 bytes at each redraw. In this test, there are 10000 rectangles so each redraw uses an additional 1.26 MB, or 1.8 GB/minute at 24 FPS...

This is because, for each item, at every redraw, a random 64-chars tag is generated. And the problem is Tcl never releases tag strings...
(see https://wiki.tcl-lang.org/page/Fixing+Tk%5FUid+leaks or https://wiki.tcl-lang.org/page/Why+does+Tcl+leak+memory%3F)

It would be great to find a way to reuse the tags instead of generating new ones each time.

Activity

  1. timothyschoen commented on Sep 16, 2026

    @timothyschoen
    Contributor

    Thanks for reporting, glad @ben-wes found the solution :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions