Opened 3 years ago

Closed 3 years ago

#1772 closed defect (fixed)

importing the same module over and over eats up more and more memory

Reported by: sjamaan Owned by:
Priority: major Milestone: 5.3
Component: unknown Version: 5.2.0
Keywords: Cc:
Estimated difficulty: hard

Description

Reported by "plugd" on IRC:

(import (chicken string)
        (chicken gc)
        (chicken io))

(let loop ()
  (print (conc "Memory statistics: " (memory-statistics)))
  (eval '(begin (import (chicken string)) (print "Hello.")))
  (read-line)
  (loop))

I checked, and CHICKEN 4 also exhibits this behaviour, so it's not something new we recently introduced (as I remember we've been putting some effort into optimizing library imports)

Change History (2)

comment:1 Changed 3 years ago by sjamaan

Milestone: 5.45.3

Ah, the optimization mentioned in the description was in merge-se, which ##sys#import does *not* use: it uses append, which is a bit of a naive way of extending the current environment. It's fine for locally scoped lets and such, which the compiler and interpreter do all over the place, but it's not fine when adding large amounts of identifiers in one go to an open-ended environment like import does.

The fix is to call merge-se; patch sent to chicken-hackers. Moving to the 5.3 milestone unless anyone objects.

comment:2 Changed 3 years ago by sjamaan

Resolution: fixed
Status: newclosed

Fixed with ff8a66a7bb180d7dce6c9a6d7cb3e5d6cb53c985

Note: See TracTickets for help on using tickets.