On Mon, 08 Apr 2013 13:28:20 +0100, Dicebot <m.stras...@gmail.com> wrote:

On Monday, 8 April 2013 at 12:22:04 UTC, Jacob Carlborg wrote:
On 2013-04-08 12:57, Regan Heath wrote:

D should have a set of global allocator hooks.  If it did, you could
easily catch unexpected allocations in tight loops and realtime code.
If it did, GC-free D would be trivial - just replace the default GC
based allocator with a malloc/free one, or any other scheme you like.

You can already do that:

https://github.com/D-Programming-Language/druntime/tree/master/src/gcstub

Not the same. Using stub gc can help finding unneeded gc allocations, but it is not designed to be generic allocator - API kind of assumes it actually is a GC. It is a starting place, but not a solution.

True, but it does help Manu with his problem of detecting unexpected GC allocations in realtime loops though.

I've always hated the fact that C++ has 2 memory models new/delete and malloc/free and I've never liked new/delete because it doesn't allow anything like realloc - why can't I reallocate an array of char or wchar_t??

So, in my ideal world - if I needed manual memory management - I would want to be able to supply one set of allocator routines malloc, realloc, free (minimum) and have the runtime use those for all memory (heap only I guess) allocation.

So, new would obtain the object memory from my routine, then do it's own (placement) construction in that memory block - for example.

It would also be nice to be able to override new, for object tracking or similar purposes.

As has been said, we no longer have delete. But, we might want to track GC collection or finalisation, again for object tracking or similar. If we get destroy we might want to hook that also.

R

--
Using Opera's revolutionary email client: http://www.opera.com/mail/

Reply via email to