Summary
importing the same module over and over eats up more and more memory
Metadata
- Id: 460e646f87c09990c154a0ae45842ec576042507
- Trac id: 1772
- Type: defect
- Reporter: sjamaan
- Owner:
- Cc:
- Status: closed
- Component: unknown
- Estimated difficulty: hard
- Resolution: fixed
- Priority: major
- Milestone: 5.3
- Version: 5.2.0
- Changetime: 2021-07-22 14:26:30 UTC
- Created: 2021-07-21 08:04:58 UTC
- Keywords:
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)
Changes and comments
[2021-07-22 13:35:09 UTC] sjamaan changed milestone from 5.4 to 5.3
[2021-07-22 13:35:09 UTC] sjamaan wrote:
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 `let`s 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.
[2021-07-22 14:26:30 UTC] sjamaan changed status from new to closed
[2021-07-22 14:26:30 UTC] sjamaan set resolution to fixed
[2021-07-22 14:26:30 UTC] sjamaan wrote:
Fixed with ff8a66a7bb180d7dce6c9a6d7cb3e5d6cb53c985