From: "Alex R. Mosteo" <devnull@mailinator.com>
Subject: Re: function "&" for strings type cause memory problem.
Date: Thu, 10 Nov 2005 10:01:31 +0100
Date: 2005-11-10T10:01:31+01:00 [thread overview]
Message-ID: <43730C6B.3080106@mailinator.com> (raw)
In-Reply-To: <dkv059$hit$1@netnews.hinet.net>
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;
>
>
next prev parent reply other threads:[~2005-11-10 9:01 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-10 8:25 function "&" for strings type cause memory problem bubble
2005-11-10 9:01 ` Alex R. Mosteo [this message]
2005-11-10 9:23 ` Dmitry A. Kazakov
2005-11-10 18:04 ` tmoran
2005-11-10 20:45 ` Jeffrey R. Carter
2005-11-11 8:25 ` bubble
2005-11-11 9:43 ` Dmitry A. Kazakov
2005-11-11 11:55 ` bubble
2005-11-11 13:45 ` Dmitry A. Kazakov
2005-12-01 0:18 ` Randy Brukardt
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox