Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 5668c4559001099e9a0ded8b76a6d2646c39761bd6eb56bdcee68d370ed3a49e
Ticket: 9a2351225c77fb4a90cf23ade237414b4f199361
32-bit build broken (test lseq-bug-54329e39c7 fails)
User & Date: dkf on 2025-06-04 13:52:58
Changes

  1. icomment:
    Looking at what the failing test does, reworking to use `memory info` is probably the best option anyway. The test is looking to verify that `foreach` doesn't force an arithmetic series object to fully instantiate... which is good, but it's doing it by using a proxy measure that could be confounded by other effects, to which it thus becomes very sensitive. The fact that it's using `[tcl::build-info purify]` as a condition to make the test meaningless is a sign that things are not healthy.
    
    ----
    
    The proof that there's nothing bad happening in the interaction between `foreach` and `lseq` is in this (with `p1` and `p2` pre-declared/executed to ensure the bytecode's already there):
    
    ```
    % proc p1 l {foreach x $l {}}
    % proc p2 l {foreach x [list 0 {*}$l] {}}
    % p1 1
    % p2 1
    % memory info
    total mallocs                 146292
    total frees                   133476
    current packets allocated      12816
    current bytes allocated       818998
    maximum packets allocated      13019
    maximum bytes allocated       853114
    
    % p1 [lseq 1 1000000]; memory info
    total mallocs                3146737
    total frees                  3133899
    current packets allocated      12838
    current bytes allocated       820140
    maximum packets allocated      13019
    maximum bytes allocated       853114
    
    % p2 [lseq 1 1000000]; memory info
    total mallocs                6147179
    total frees                  6134325
    current packets allocated      12854
    current bytes allocated      9201511
    maximum packets allocated    3012872
    maximum bytes allocated    141202167
    
    ```
    Notably, the expansion of the sequence to make a standard list (plus one element) results in a vastly higher peak memory usage, as expected.
    
    And I'm concerned that there's so much memory still allocated in this case. There appears to be a leak!
    
  2. login: "dkf"
  3. mimetype: "text/x-markdown"