Uploaded image for project: 'core.async'
  1. ASYNC-219

some locals are not cleared in go blocks

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Labels:
      None

      Description

      Running this code eventually throws OOME :

      (let [c (a/chan)]
        (a/go (while (a/<! c)))
        (a/go
          (when-some [xs (range)]
            (doseq [x xs]
              (a/>! c x)))))
      

      This one (with let instead of when-some) works fine :

      (let [c (a/chan)]
        (a/go (while (a/<! c)))
        (a/go
          (let [xs (range)]
            (doseq [x xs]
              (a/>! c x)))))
      

      In the former, the range seq is stored on the heap (in go block's state array) and retained for the whole doseq iteration, althought it's not needed anymore after loop initialization.
      In the latter, the range seq is stored on the stack so the compiler is able to perform its local clearing magic.

      This behavior is likely to happen for every value spanning across multiple ssa blocks.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              leonoel leonoel
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated: