🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.linux.misc
Article #515

Re: g77, release memory used for local variables ?

#515
From: KOMATSUZAKI Tamiki
Date: Fri, 13 Feb 1998 00:00
67 lines
2832 bytes

>But wait a minute, it actually _uses_ 160Mb! In your example compiler
>could optimize it away (well, it could optimize away the whole thing)
>but consider the following modification:
>        caller allocates 80Mb array and writes something there;
>        test1 also allocates 80Mb and uses it;
>        test1 finishes and deallocate his 80Mb;
>        after that the caller continues to use _his_ array.
>When the test1 runs it should have 80Mb for its own array _and_ the first
>array should be preserved somewhere. After all, caller would be very upset
>if his very own array would disappear or would lose its content. So when
>the test1 is being executed you need 160Mb total. No matter where you'll
>place it, but you can't get out alive without this amount under any system
>with any compiler.

        I am sorry but that example was wrong as you pointed out.
What I want to ask you and other Linux users is,say, 

in the following test program;

 
        program test
        integer n
        n = 1
        call test1(n)
        call test2(n)
        stop
        end 
        subroutine test1(j)
        integer m,j,k
        parameter(m=20000000) ! =80MB
        dimension k(m)
        return
        end 
        subroutine test2(j)
        integer m,j,k
        parameter(m=20000000) ! =80MB
        dimension k(m)
        return
        end 

each subroutine will allocate 80 MB but should also deallocate 80MB when  
it exits to caller. thus, even if one has 100 MB memory in one's system,
this program should properly work when you deallocate the memory space
which was used for local variables and arrays in each subroutine. 
I tried to compile this program by g77 compiler with -fno-automatic or/and
-fno-caller-saves options but segmentation fault error was still appeared.



what should I do ?




I would GREATLY appreciate  you if you comment on this.





thanks.

Tamiki Komatsuzaki
Department of Chemistry, The univ. of Chicago
email: tamiki@cloister.uchicago.edu
Technical Details
Message-ID: <6c103q$bjt$1@gekigan.nips.ac.jp>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <6c0k7v$hb9@riemann.math.psu.edu>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1103af,b22f12d0b3d158d4
X-Google-Attributes: gid1103af,public
X-Google-Thread: 10684a,b22f12d0b3d158d4
X-Google-Attributes: gid10684a,public
X-Google-Thread: f9b51,b22f12d0b3d158d4
X-Google-Attributes: gidf9b51,public
X-Google-Thread: 102983,b22f12d0b3d158d4
X-Google-Attributes: gid102983,public
From: ib0@ccfep1.ims.ac.jp (KOMATSUZAKI Tamiki)
Subject: Re: g77,  release memory used for local variables ?
Date: 1998/02/13
Message-ID: <6c103q$bjt$1@gekigan.nips.ac.jp>
X-Deja-AN: 324701295
References: <6c0k7v$hb9@riemann.math.psu.edu>
Organization: National Institute for Physiological Sciences, Okazaki, Japan
Newsgroups: comp.os.linux.misc,comp.os.linux.setup,fj.os.linux,aus.computers.linux