Clojure

Multi-methods hold onto the head of their arguments

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: Release 1.2
  • Fix Version/s: Release 1.3
  • Component/s: None
  • Labels:
    None
  • Patch:
    Code
  • Approval:
    Ok

Description

Multi-methods hold onto the head of their arguments when they are invoked. This means that if you invoke a multi-method with a lazy seq that cannot be held in memory all at once, you blow heap.

I'm not sure how best to write a test case for this particular issue, since the easiest way to test it is to run the JVM with a small heap and purposely evoke an OutOfMemoryError, so the attached patch has only the code changes. (However, I have verified the fix using a small heap.)

This will fix the issue for arities up to 6, for arities >=7 there is a bug in RestFn where it also holds the head of its arguments. If it is desirable to fix that bug as well, then I can submit a patch for it.

  1. muli-method-holds-head.diff
    08/Jan/11 10:02 AM
    23 kB
    Paul Stadig
  2. multi-and-rest-fn-fix.patch
    04/Feb/11 8:21 AM
    212 kB
    Paul Stadig
  3. multi-and-rest-fn-fix-unix.patch
    22/Feb/11 11:45 PM
    208 kB
    Matthew Lee Hinman

Activity

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: