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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,eb896440a3af23cf X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!news-in.ntli.net!newsrout1-win.ntli.net!ntli.net!newspeer1-win.ntli.net!newsfe3-gui.ntli.net.POSTED!53ab2750!not-for-mail From: "Dr. Adrian Wrigley" Subject: Re: large arrays User-Agent: Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.) Message-Id: Newsgroups: comp.lang.ada References: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Date: Wed, 10 Nov 2004 03:45:25 GMT NNTP-Posting-Host: 81.100.88.147 X-Complaints-To: http://www.ntlworld.com/netreport X-Trace: newsfe3-gui.ntli.net 1100058325 81.100.88.147 (Wed, 10 Nov 2004 03:45:25 GMT) NNTP-Posting-Date: Wed, 10 Nov 2004 03:45:25 GMT Organization: ntl Cablemodem News Service Xref: g2news1.google.com comp.lang.ada:6099 Date: 2004-11-10T03:45:25+00:00 List-Id: On Tue, 09 Nov 2004 23:55:00 +0000, Jeff C r e e.m wrote: > From the GNAT RM (6.2) > > The largest Size value permitted in GNAT is 2**31-1. Since this is a Size > in bits, this corresponds to an object of size 256 megabytes (minus one). > This limitation is true on all targets. The reason for this limitation is > that it improves the quality of the code in many cases if it is known that a > Size value can be accommodated in an object of type Integer. This is a real pain sometimes! The limitation crops up in various annoying places, even in code you thought worked (eg generic instantiatian?). There are rules that allow you to work with large objects, for example Don't use 'Size - it doesn't work Don't declare types > 256MB with static sizes Try something like: type Site is array (1..3) of Short_Short_Integer; -- size=24 bits type Site_Matrix is array (Integer range <>, Integer range <>) of Site; type Site_Matrix_A is access Site_Matrix; My_Array: Site_Matrix_A := new Site_Matrix(1..1_132_000,1..72); One area this I have encountered this is with image processing, where even standard IMAX frames might be 6144x4096 pixels, held as floating point RGBA come to about 400MB. Currently, I have a record of 1800MB, which I mmap into a file for shared access and persistence. This works extremely well, other than having to calculate 'Size by another method. I'm a bit disappointed to hear that the restriction exists even on 64-bit targets - at the moment, I have 6GB RAM+Swap, and it is annoying that I can only access 5% of that with any single object in Ada. Of course there are those who might argue that there must something wrong with the programming approach if objects get this large... but that's another argument. -- Dr. Adrian Wrigley, Cambridge, UK.