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,90e73a4812231b54 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!feeder3.cambrium.nl!feed.tweaknews.nl!213.132.189.1.MISMATCH!multikabel.net!feed10.multikabel.net!hwmnpeer01.ams!news.highwinds-media.com!news.astraweb.com!newsrouter-eu.astraweb.com!news.tele.dk!news.tele.dk!small.news.tele.dk!uio.no!fi.sn.net!newsfeed1.fi.sn.net!news.song.fi!not-for-mail Date: Sat, 09 Jun 2007 08:25:54 +0300 From: Niklas Holsti User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20060628 Debian/1.7.8-1sarge7.1 X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Memory Useage References: <1181335115.659050.135860@q69g2000hsb.googlegroups.com> In-Reply-To: <1181335115.659050.135860@q69g2000hsb.googlegroups.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <466a398f$0$8390$39db0f71@news.song.fi> Organization: TDC Song Internet Services NNTP-Posting-Host: laku61.adsl.netsonic.fi X-Trace: 1181366671 news.song.fi 8390 81.17.205.61:32799 X-Complaints-To: abuse@song.fi Xref: g2news1.google.com comp.lang.ada:16132 Date: 2007-06-09T08:25:54+03:00 List-Id: mhamel_98@yahoo.com wrote: > Hello c.l.a. Another question, I have a program that stores data on > the disk using sequential_io. When I later read that data into an > array, the memory growth after ingesting a file is much much larger > than the disk footprint. A file that takes 26.8MB on disk (over 134k > records) causes the program to swell by over 600MB! Holy bloatware. > A short overview of what I'm trying to do - each sequential_io data > file has an associated header file with stuff like number of records, > etc. The header is read, and an array is then created based on how > many records are said to be in the data file. The data file is then > read, sticking a node into the array. Some abbreviated code below, > the spec: > > generic > type Node_Type is private; > package Node_Manager is > > package Seq is new Sequential_Io (Node_Type); > > type Node_Array is array (positive range <>) of Node_Type; > type Node_Ptr is access Node_Array; Is the actual type for Node_Type a record type with variants? If so, is the size of the largest variant much larger than the size of the most common variants? I don't know about ObjectAda, but in GNAT the Node_Array would have a size that lets you store the largest variant in every array element, while the Node_Type objects stored in the sequential_io file probably use only as much file-space as the actual variant of each object requires. The solution in GNAT would be to allocate storage for each Node_Type object separately and have an array of accesses: type Node_Ptr is access Node_Type; type Node_Array is array (positive range <>) of Node_Ptr; type Node_Array_Ptr is access Node_Array; This increases memory overhead by allocating more blocks from the heap, but it may reduce the overall memory requirement if the largest variant of Node_Type is much larger than the average variant. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .