Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Getting garbage collection with iterative processes
#1
Rainbow 
With the following example code, I'm still getting garbage collection messages with large numbers:

Code:
(define (useless-counter i)
   (define (useless-iter total n)
      (if (<= n 0)
         total
         (useless-iter (+ total 1) (- n 1)))
      )
   )
   (useless-iter 0 i)
)

I'm not sure what is going on. I'm quite certain I have an iterative process, but have no idea as to why garbage collection is happening. Any thoughts / suggestion / help?
Ah geez Rick... wh-- why you turn yourself into a pickle?
Reply
#2
Just because a process is iterative, doesn't mean that it is not using memory. Scam doesn't reuse stack frames upon tail recursion, it throws the uneeded ones away to be garbage collected. The same is true for Scheme (at least the implementations with which I am familiar).
Reply
#3
So would I be having an issue with my linux environment? I'm actually getting garbage collection at medium size numbers (100k).
Ah geez Rick... wh-- why you turn yourself into a pickle?
Reply
#4
Scam allocates a very small amount of initial memory. So it garbage collects early and often.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)