[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROG] Store arrays i Ada



Anders Lyckegaard skrev:

> Jeg har et problem med allokering af en stor array i ADA.

"Ada", det er ikke et akronym.

> Hvis en array bliver af en given størrelse får jeg en
> "segmentation fault", når jeg forsøger at køre
> programmet.

GNU Ada allokerer som standard lokale variable i en
procedure på stakken. Og Linux har typisk en grænse for hvor
stor en stak dine programmer må have.

Der er to muligheder:

 1) Bede Linux om at give dit program lov til at have en
    større stak. Kommandoen:

       limit stacksize 16M

    var nok til at få dit program til at køre fint med den
    lave grænse.

 2) Allokere den store variabel på "heap"en:

          type Work_Array is array (1 .. LWA) of Long_Float;
          type Work_Array_Reference is access all Work_Array;

          WA : Work_Array_Reference;

       begin
          WA := new Work_Array_Reference'(others => 0.0);

> Hvis jeg laver array'en endnu større får jeg en "raise
> STORAGE_ERROR :  test_array.ada:7", når jeg forsøger at
> køre programmet.

Den fejl er det lidt sværere at slippe af med. Hvis du
allokerer variablen på "heap"en, men undlader at
initialisere den samtidig går det fint:

   WA := new Work_Array_Reference

Jeg kan ikke forstå hvorfor man ikke får lov til at fylde
data i variablen samtidig.

> Jeg formoder det har noget at gøre med, hvor meget
> hukommelse jeg har til rådigheden, men der er masser af
> fysisk hukommelse, så det burde ikke være problemet.

Korrekt. Det handler om hvor meget du har givet dig selv lov
til at bruge til forskellige formål.

Jacob
-- 
"In space, no-one can press CTRL-ALT-DEL"
                                        -- An Ada programmer



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 19:58 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *