From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,126b9ecb088e6bfd X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-10-12 16:24:07 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!in.100proofnews.com!in.100proofnews.com!attla2!ip.att.net!attbi_feed3!attbi_feed4!attbi.com!sccrnsc04.POSTED!not-for-mail Message-ID: <3F89E26E.40705@comcast.net> From: "Robert I. Eachus" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20021120 Netscape/7.01 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: using 'storage_size ? References: <3f8904a1$0$10406$626a54ce@news.free.fr> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 24.34.139.183 X-Complaints-To: abuse@comcast.net X-Trace: sccrnsc04 1066001046 24.34.139.183 (Sun, 12 Oct 2003 23:24:06 GMT) NNTP-Posting-Date: Sun, 12 Oct 2003 23:24:06 GMT Organization: Comcast Online Date: Sun, 12 Oct 2003 23:24:06 GMT Xref: archiver1.google.com comp.lang.ada:753 Date: 2003-10-12T23:24:06+00:00 List-Id: Alex Xela wrote: > > with ada.text_io,Unchecked_Deallocation,Ada.Exceptions; > procedure garbage is > ko : constant := 1024; > Mo : constant := ko*ko; ... > declare > type local_ptr is access tab_byte; > for local_ptr'storage_size use Mo*8;--[line 20]GNAT 3.15p raised > STORAGE_ERROR : EXCEPTION_STACK_OVERFLOW Read the fine manual. In this case the gnat_rm will point you to System.Pool_Size in s-poosiz.ads which says: ----------------------------------------------------------------------------- ------------------------ -- Stack_Bounded_Pool -- ------------------------ -- Allocation strategy: -- Pool is a regular stack array, no use of malloc -- user specified size -- Space of pool is globally reclaimed by normal stack management -- Used in the compiler for access types with 'STORAGE_SIZE rep. clause -- Only used for allocating objects of the same type. ---------------------------------------------------------------------------- Translation, when you use 'Storage_Size in GNAT to set the storage for a type, the compiler takes that as a directive to allocate a local_ptr'storage_size array on the stack, in this case as part of the stack frame for the declare block. If you comment the line out, the storage designated by local_ptr values will be allocated on the heap when new is called. I suspect that you need to grow the stack size if you want to grab a megabyte in one chunk. -- Robert I. Eachus "Quality is the Buddha. Quality is scientific reality. Quality is the goal of Art. It remains to work these concepts into a practical, down-to-earth context, and for this there is nothing more practical or down-to-earth than what I have been talking about all along...the repair of an old motorcycle." -- from Zen and the Art of Motorcycle Maintenance by Robert Pirsig