Re: JavaMemoryModel: Out-of-scope variables and finalization

From: Doron Rajwan (doron@rajwan.org)
Date: Sat Oct 18 2003 - 10:49:16 EDT


As strange as it sound, C++ implementations suffer from the same
problem. The code below will run out-of-memory faster than you would
expect:

 

        int fib(int n) {

            if (n <= 1) {

                int a[10000]; // do we have multiple copies in stack?

                return 1;

            } else {

                return fib(n) + fib(n-1);

            }

        }

 

Doron.

      

 

_______________________________________________

Doron Rajwan, doron@rajwan.org, www.rajwan.org <http://www.rajwan.org/>

13 Odem street, Rishon Le-Zion, Israel

Home: 03-9512348 [+972-(3)-9512348]

Cell: 064-887732 [+972-(64)-887732]

 

-------------------------------
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel



This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:51 EDT