comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: Problems with Scope of aliased Objects
Date: Thu, 16 Apr 2009 09:26:17 -0700 (PDT)
Date: 2009-04-16T09:26:17-07:00	[thread overview]
Message-ID: <7f791896-0395-4471-910f-afaf8a488a13@r31g2000prh.googlegroups.com> (raw)
In-Reply-To: 40ae6bc2-2830-429a-a8e9-81b6b7604781@o11g2000yql.googlegroups.com

On Apr 16, 8:59 am, "patrick.gu...@googlemail.com"
> Alright, this was my explanation. I forgot the fact, that the values
> are copied into the array. The simple reason why I didn´t want to use
> heap-memory is the performance-aspect. My third approach works using
> "new" to allocate heap-memory dynamically. In this case, adding the
> access-type into the array leads to a copy of the heap-memory-adress
> where the object was created. This address is copied into the array
> and thus still reachable. To cut a long story short, my second
> approach simply won´t work because of dangling pointers which point to
> memory which isn´t assigned any longer (at least not to the objects I
> expect to be there). Do I have to be afraid of runtime-performance-
> problems when using dynamic allocation in Ada?

I don't know.  That will depend on which implementation of Ada you use
and just what your performance requirements are.  If it's really a
concern, you can set up your own storage pool, with your own
allocation and deallocation routines, and tell the compiler that any
time you use "new" for certain access types, they will use that pool.
Then you can optimize the pool routines and tailor them to the
specific way you will use it (for example, if you never deallocate
anything, you can take advantage of that fact to simply the Allocate
routine; or you can organize the pool so that all objects of the same
size will be next to each other, which could lead to a more efficient
implementation).  Storage pools are explained in 13.11 of the RM, and
there may be other helpful resources, and I'm sure there are publicly
available examples of storage pools that you can use or modify---but I
don't know where they are, so hopefully someone else can point you to
them.

                              -- Adam




  reply	other threads:[~2009-04-16 16:26 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-16 13:43 Problems with Scope of aliased Objects patrick.gunia
2009-04-16 15:29 ` Adam Beneschan
2009-04-16 15:59   ` patrick.gunia
2009-04-16 16:26     ` Adam Beneschan [this message]
2009-04-16 16:37       ` patrick.gunia
2009-04-16 20:11       ` Adam Beneschan
2009-04-16 15:47 ` Dmitry A. Kazakov
2009-04-16 19:12   ` sjw
2009-04-16 15:50 ` Ludovic Brenta
2009-04-16 16:01   ` Adam Beneschan
2009-04-16 16:12     ` patrick.gunia
2009-04-17 13:53       ` Alex R. Mosteo
replies disabled

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