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-Thread: 103376,23ace43a488fab29 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news2.volia.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Alex R. Mosteo" Newsgroups: comp.lang.ada Subject: Re: function "&" for strings type cause memory problem. Date: Thu, 10 Nov 2005 10:01:31 +0100 Message-ID: <43730C6B.3080106@mailinator.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net zNFAwxL0OWGAO2aDoK8i5QXxY+LhakK9XwXlA3GjSYiT9d5xI= User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051013) X-Accept-Language: en-us, en In-Reply-To: Xref: g2news1.google.com comp.lang.ada:6336 Date: 2005-11-10T10:01:31+01:00 List-Id: bubble wrote: > dear all: > I have a project need mix 2 language (VB and Ada). > > > VB do GUI and monitor the real time quote then trigger kernel work. > Ada with gnatcom to do kernel work (financial model pricing). > > in the project, a code snip will raise storage_error excpeiton because I > combine 2 BIG string to 1 string. > > I test the code snip and I get some problem in the statement, Nstring2 := > new String'(String1 & String2) . > > if I compiling the code to stand alone execute file and enable pragma > Linker_Options ("-Wl,--stack=0x10000000"); > It both passed. > if I compiling it to DLL ,it pass test 1 and fail in test2 > > Test 1 | > Test 2 > ----------------------------------------------------------------------------------------------- > .exe with Linker_Options | Pass > Pass > .exe without Liner_Options | Pass Fail > .dll with Linker_Options | Pass > Fail > .dll without Linker_Options | Pass > Fail > > Test Environment > ---------------------------------------------------------------------------------------------- > OS:Windows XP. > memory :640 MB. > VB: Microsoft Visual Basic 6 > gnatcom version: 1.4 > ada compiler: Gnat GPL 2005 > > > > I guess functin "&" for string type may have potential problem in gnat > windows editions. > does any body know the problem and give me some suggestion. > thanks This is just stack exhaustion. You can try either configuring your stack size big enough for any string in your system, or using Unbounded_String which uses memory from the heap. Though if you end converting them to regular String at some point I reckon you may have the same problem. > Test Code > -------------------------------------------------------------------------------------------------- > with Ada.Text_IO; > Use Ada.Text_Io; > > procedure test is > --pragma Linker_Options ("-Wl,--stack=0x10000000"); > type access_string is access all String; > String1 : String := (1 .. 10_000_000 => 'a'); > String2 : String := (1 .. 10_000_000 => 'b'); > > begin > declare > nString : access_string := null; > begin > nString:= new String (1 .. String1'Length + String2'Length); > nString.all (String1'First .. String2'Last) := String1; > nString.all ( String1'First + String2'First.. String1'First + > String2'Last):= String2; > Put_Line("Test 1 Passed"); > Exception > When Others=> > Put_Line("Test 1 Fail"); > end; > declare > Nstring2 : access_string := null; > begin > Nstring2 := new String'(String1 & String2); > Put_Line("Test 2 Passed "); > exception > when others => > Ada.Text_IO.Put_Line ("Test 2 Fail"); > end; > end test; > >