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=3.8 required=5.0 tests=BAYES_00,INVALID_MSGID, RATWARE_MS_HASH,RATWARE_OUTLOOK_NONAME autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a41bdc9275138107 X-Google-Attributes: gid103376,public From: "Nick Roberts" Subject: Re: Dynamic Allocation problem Date: 1997/04/05 Message-ID: <01bc41d5$caf49f80$c2fa82c1@xhv46.dial.pipex.com>#1/1 X-Deja-AN: 230925040 References: <5i436p$248c@newssvr01-int.news.prodigy.com> Organization: UUNet PIPEX server (post doesn't reflect views of UUNet PIPEX) Newsgroups: comp.lang.ada Date: 1997-04-05T00:00:00+00:00 List-Id: Matthew Givens wrote in article <5i436p$248c@newssvr01-int.news.prodigy.com>... > Okay, I'm working on an Ada program that uses a LOT of dynamic allocation. > > > The program is supposed to retrieve records from an ORACLE database and > load them into a Listbox (I'm running on a Sun). It works fine for about > 1600 records, then croaks on an attempt to dynamically allocate the new > memory. > > The listbox data is stored (don't blame me, I didn't design it) in one > large string, each row separated by LF's. Only 100 rows at a time are > actually displayed, but all rows are stored in the string. Now, at the > time of the crash, the listbox string takes up approx 300K, with the new > row taking up 230 bytes. When I try to allocate the new memory (using > new), it dies with a STORAGE_ERROR exception. > > Now, is there any way for me to check the amount of available storage > BEFORE I actually try the allocation? It would be helpful to me in > debugging if I could tell how close to the memory limit I am at any given > point, but I don't know how to do this. Any help is appreciated. One way is simply to use an exception handler to catch the Storage_Error exception, and then take appropriate action. Perhaps, in your case, if the exception happens, all you need to do is display a message (in a dialog) to the user to the effect that not all the data could be presented in one go, then display the list data which could be loaded, and provide an option (perhaps an extra button) to allow the remaining data to be loaded and presented. Of course, your application may not be as simple as that. You may want to put the loader code into a separate procedure, which returns a flag indicating whether all the data was loaded or not. The procedure would initialise the flag to 'all data loaded', but the exception handler would set it to 'not all loaded'. Nick.