comp.lang.ada
 help / color / mirror / Atom feed
* Memeory management
@ 2005-09-05 21:02 Zheng Wang
  2005-09-05 21:43 ` tmoran
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Zheng Wang @ 2005-09-05 21:02 UTC (permalink / raw)


 Hi, My program is compiled by ObjectAda and ran on Windows, then it
returns code 128(a correct program should return code 0). I found that
there are too many variables declared and after I merged some
variables(number of variables deduced), it does work perfectly. I
wonder that are there any constrains on the memory allocated for
variable declaraions? However, I did not allocate and deallocate memory
as I did in C, does Ada provide automatically garbage collection? How
could I handle this case if I can not deduce the number of variables
declared? Many thanks.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Memeory management
  2005-09-05 21:02 Memeory management Zheng Wang
@ 2005-09-05 21:43 ` tmoran
  2005-09-22 15:23   ` adaworks
  2005-09-05 21:45 ` jimmaureenrogers
  2005-09-06 16:45 ` Martin Krischik
  2 siblings, 1 reply; 6+ messages in thread
From: tmoran @ 2005-09-05 21:43 UTC (permalink / raw)


>wonder that are there any constrains on the memory allocated for
>variable declaraions? However, I did not allocate and deallocate memory
>as I did in C, does Ada provide automatically garbage collection?
  A particular Ada compiler, with a particular set of compile options,
and a particular OS, and a particular target machine, will of course
have some particular memory limitation.  How much memory do you need?
  If you declare variables in the ordinary way, e.g.
    procedure P(N : Positive) is
      Vector : array(1 .. N) of Integer;
      Bigger_Vector : array(1 .. 5*N) of Integer;
      Var1, Var2 : Float;
    begin
Ada will automatically allocate space for Vector, Bigger_Vector, Var1, and
Var2 at the beginning and deallocate on exit.
  If you allocate explicitly from the heap using access types (pointers)
and "new" then the Ada specification does not say whether the
implementation must do automatic garbage collection or not.  Most don't,
so you would need to explicitly use Ada.Unchecked_Deallocation to do your
deallocations.  (Many Ada applications are real time and it would be be
Bad if your train control program started doing extensive garbage
collection just when a sensor detected an obstacle on the track.)



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Memeory management
  2005-09-05 21:02 Memeory management Zheng Wang
  2005-09-05 21:43 ` tmoran
@ 2005-09-05 21:45 ` jimmaureenrogers
  2005-09-06 16:45 ` Martin Krischik
  2 siblings, 0 replies; 6+ messages in thread
From: jimmaureenrogers @ 2005-09-05 21:45 UTC (permalink / raw)



Zheng Wang wrote:
> Hi, My program is compiled by ObjectAda and ran on Windows, then it
> returns code 128(a correct program should return code 0). I found that
> there are too many variables declared and after I merged some
> variables(number of variables deduced), it does work perfectly. I
> wonder that are there any constrains on the memory allocated for
> variable declaraions? However, I did not allocate and deallocate memory
> as I did in C, does Ada provide automatically garbage collection? How
> could I handle this case if I can not deduce the number of variables
> declared? Many thanks.

Is this the free version of ObjectAda? If so, then you are using
a compiler that has significant restrictions on the number of
variables and threads it can handle.

You might want to try another compiler. Try the GNAT compiler if
you still want a free compiler.

Jim Rogers




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Memeory management
  2005-09-05 21:02 Memeory management Zheng Wang
  2005-09-05 21:43 ` tmoran
  2005-09-05 21:45 ` jimmaureenrogers
@ 2005-09-06 16:45 ` Martin Krischik
  2 siblings, 0 replies; 6+ messages in thread
From: Martin Krischik @ 2005-09-06 16:45 UTC (permalink / raw)


Zheng Wang wrote:

>  Hi, My program is compiled by ObjectAda and ran on Windows, then it
> returns code 128(a correct program should return code 0). I found that
> there are too many variables declared and after I merged some
> variables(number of variables deduced), it does work perfectly. I
> wonder that are there any constrains on the memory allocated for
> variable declaraions? However, I did not allocate and deallocate memory
> as I did in C, does Ada provide automatically garbage collection?

Ada *may* have automatically garbage collection - with emphasis on *may* -
In ObjectAda the garbage collection is provided only for JVM as target

> How 
> could I handle this case if I can not deduce the number of variables
> declared? Many thanks.

See http://en.wikibooks.org/wiki/Ada_Programming/Memory

Regards

Martin
-- 
mailto://krischik@users.sourceforge.net
Ada programming at: http://ada.krischik.com



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Memeory management
  2005-09-05 21:43 ` tmoran
@ 2005-09-22 15:23   ` adaworks
  2005-09-22 17:11     ` Martin Krischik
  0 siblings, 1 reply; 6+ messages in thread
From: adaworks @ 2005-09-22 15:23 UTC (permalink / raw)



<tmoran@acm.org> wrote in message news:naidnWP4ToNgJoHeRVn-2g@comcast.com...
>
>   If you allocate explicitly from the heap using access types (pointers)
> and "new" then the Ada specification does not say whether the
> implementation must do automatic garbage collection or not.  Most don't,
>
Because Ada does not prohibit automatic garbage collection, it would seem
like a good idea to have it as a compile-time option in a well-designed
compiler.   Yes, it is a lot of work, but for most programs, not
safety-critical,
and running under a commercial OS, it would make sense.

Richard Riehle





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Memeory management
  2005-09-22 15:23   ` adaworks
@ 2005-09-22 17:11     ` Martin Krischik
  0 siblings, 0 replies; 6+ messages in thread
From: Martin Krischik @ 2005-09-22 17:11 UTC (permalink / raw)


adaworks@sbcglobal.net wrote:

> 
> <tmoran@acm.org> wrote in message
> news:naidnWP4ToNgJoHeRVn-2g@comcast.com...
>>
>>   If you allocate explicitly from the heap using access types (pointers)
>> and "new" then the Ada specification does not say whether the
>> implementation must do automatic garbage collection or not.  Most don't,
>>
> Because Ada does not prohibit automatic garbage collection, it would seem
> like a good idea to have it as a compile-time option in a well-designed
> compiler.   Yes, it is a lot of work, but for most programs, not
> safety-critical,
> and running under a commercial OS, it would make sense.

Well I had a go on this allready:

http://adacl.sourceforge.net/pmwiki.php/Main/GarbageCollector

Using storrage pools is actually better then compiler options - sure more
typing work - but what happens if GC and non-GC packages are linked with
each other?

The only thing what bothers me is finalisation - with lots of GNAT source
browsing and intermediate code listing I got it implemented - but I it
would be better if GC storrage pools where incorporated right into the
compiler .

Martin

-- 
mailto://krischik@users.sourceforge.net
Ada programming at: http://ada.krischik.com



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-09-22 17:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-05 21:02 Memeory management Zheng Wang
2005-09-05 21:43 ` tmoran
2005-09-22 15:23   ` adaworks
2005-09-22 17:11     ` Martin Krischik
2005-09-05 21:45 ` jimmaureenrogers
2005-09-06 16:45 ` Martin Krischik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox