Using the stack and garbage collector?
Hi! The following expression give me 102: -=â=-=-=â=-=-=â=-=-=â=-= old := Smalltalk vm parameterAt: 9. 15000 factorial. new := Smalltalk vm parameterAt: 9. new - old -=â=-=-=â=-=-=â=-=-=â=-= I find that surprising. Why is the garbage collector used if factorial solely use the stack? Cheers, Alexandre -- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
15000! is a huge number, this computation involves large integer arithmetic. Large integers are allocated on the heap. Try a small number (to stay within Small integer range) and you'll see there is no GC activity. BTW, the implementation of #factorial is not the correct algorithm when speed and efficient large integer arithmetic are required. Please use the pharo-user ML for these kind of general questions.
On 22 May 2016, at 20:12, Alexandre Bergel <alexandre.bergel@me.com> wrote:
Hi!
The following expression give me 102: -=â=-=-=â=-=-=â=-=-=â=-= old := Smalltalk vm parameterAt: 9. 15000 factorial. new := Smalltalk vm parameterAt: 9. new - old -=â=-=-=â=-=-=â=-=-=â=-=
I find that surprising. Why is the garbage collector used if factorial solely use the stack?
Cheers, Alexandre -- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
Very right! I should have guessed this. Thanks! Cheers, Alexandre
On May 22, 2016, at 3:46 PM, Sven Van Caekenberghe <sven@stfx.eu> wrote:
15000! is a huge number, this computation involves large integer arithmetic. Large integers are allocated on the heap. Try a small number (to stay within Small integer range) and you'll see there is no GC activity.
BTW, the implementation of #factorial is not the correct algorithm when speed and efficient large integer arithmetic are required.
Please use the pharo-user ML for these kind of general questions.
On 22 May 2016, at 20:12, Alexandre Bergel <alexandre.bergel@me.com> wrote:
Hi!
The following expression give me 102: -=â=-=-=â=-=-=â=-=-=â=-= old := Smalltalk vm parameterAt: 9. 15000 factorial. new := Smalltalk vm parameterAt: 9. new - old -=â=-=-=â=-=-=â=-=-=â=-=
I find that surprising. Why is the garbage collector used if factorial solely use the stack?
Cheers, Alexandre -- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
-- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
participants (2)
-
Alexandre Bergel -
Sven Van Caekenberghe