🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.os.linux.misc
3 messages
3 total messages Started by mKsataka nagaoka Fri, 13 Feb 1998 00:00
g77, release memory used for local variables ?
#513
Author: mKsataka nagaoka
Date: Fri, 13 Feb 1998 00:00
37 lines
1810 bytes

I have been trying to release memory space used locally for every local 
variable and array referenced in subroutines or functions except common
blocks.

namely, 
suppose that we have a 100MB memory(say, real memory 32MB and swap 68MB)
and want to run a following program for an example ;

        program test
        integer i,m
        parameter(m=20000000)
        dimension i(m)      ! 20MB*4 = 80MB
        call test1
        stop
        end 
        subroutine test1
        integer m,k
        parameter(m=20000000)
        dimension k(m)      ! 20MB*4 = 80MB 
        return
        end 


I think this problem is one of basic problems and I must be
able to do it by refering g77 manual carefully. However, I tried g77 
compiler with several options, I have not found the way to overcome.
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

this mail was sent through my friend's account.
Re: g77, release memory used for local variables ?
#514
Author: Alexander Viro
Date: Fri, 13 Feb 1998 00:00
16 lines
1557 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.
								Al
Re: g77, release memory used for local variables ?
#512
Author: Rowan Hughes
Date: Sun, 15 Feb 1998 00:00
29 lines
1833 bytes
mKsataka nagaoka <c54213@sakura.kudpc.kyoto-u.ac.jp> wrote:

: I have been trying to release memory space used locally for every local 
: variable and array referenced in subroutines or functions except common
: blocks.

: namely, 
: suppose that we have a 100MB memory(say, real memory 32MB and swap 68MB)
: and want to run a following program for an example ;

:         program test
:         integer i,m
:         parameter(m=20000000)
...

Once a page is allocated to a pid/uid it cannot be released back
into the system until the job exits. It may be demalloced
but it is still owned by you until the job is done. With g77 
spaced is not allocated until a peek/poke is actually performed
on the address. That is, declaring a huge array will not consume
a huge amount of memory until you actally attempt to use values
from the array.

-- 
=======================================================
Dr Rowan Hughes                  hughesr@dnr.qld.gov.au
Qld Dept Natural Resources           x-csrdh@jcu.edu.au
CIS group, Indooroopilly. W:07-38969705   H:07-33798689
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads