digitalmars.D - std.container / tightArray / class (de)allocators
- =?iso-8859-1?Q?Robert_M._M=FCnch?= (10/10) Jun 15 2010 Hi, since std.container is now part of the DMD compiler and class
- =?iso-8859-1?Q?Robert_M._M=FCnch?= (5/14) Jun 15 2010 Has noone a tipp for me how to make & use an own allocator?
- Andrei Alexandrescu (5/18) Jun 15 2010 Sorry for being slow on that. Currently TightArray (renamed to Array)
- Stephan (14/32) Jun 16 2010 Btw. I downloaded the new dmd(2047) and tried to use this new Array
- Lars T. Kyllingstad (4/22) Jun 16 2010 It's a bug (and a strange one at that). I've checked in a fix, see:
- Stephan (2/24) Jun 16 2010 thanks for that, i hope its in the next release.
- =?iso-8859-1?Q?Robert_M._M=FCnch?= (7/10) Jun 16 2010 Hi Andrei, ok. At least it's a chart. I'm going to take a look and
- BLS (5/15) Jun 16 2010 HM''''
- =?iso-8859-1?Q?Robert_M._M=FCnch?= (19/22) Jun 16 2010 The idea is quite simple (not so much dependend on Array):
Hi, since std.container is now part of the DMD compiler and class allocators/deallocaters are no longer part of the language, the way to go now, as far as I understand now, it to use tightArray. So, how to use tightArray to allocate structs and classes from a specific memory pool? Will such allocations be under GC control or not? For example: How do I ensure that an allocation is done from a memory-mapped file area? --- Robert M. Münch http://www.robertmuench.de
Jun 15 2010
On 2010-06-15 09:49:29 +0200, Robert M. Münch said:Hi, since std.container is now part of the DMD compiler and class allocators/deallocaters are no longer part of the language, the way to go now, as far as I understand now, it to use tightArray. So, how to use tightArray to allocate structs and classes from a specific memory pool? Will such allocations be under GC control or not? For example: How do I ensure that an allocation is done from a memory-mapped file area?Has noone a tipp for me how to make & use an own allocator? --- Robert M. Münch http://www.robertmuench.de
Jun 15 2010
Robert M. Münch wrote:On 2010-06-15 09:49:29 +0200, Robert M. Münch said:Sorry for being slow on that. Currently TightArray (renamed to Array) uses hardcoded calls to malloc and free. I'd be glad to use a better design if one came along. AndreiHi, since std.container is now part of the DMD compiler and class allocators/deallocaters are no longer part of the language, the way to go now, as far as I understand now, it to use tightArray. So, how to use tightArray to allocate structs and classes from a specific memory pool? Will such allocations be under GC control or not? For example: How do I ensure that an allocation is done from a memory-mapped file area?Has noone a tipp for me how to make & use an own allocator?
Jun 15 2010
On 16.06.2010 08:59, Andrei Alexandrescu wrote:Robert M. Münch wrote:Btw. I downloaded the new dmd(2047) and tried to use this new Array template. But it does not seem to work: import std.container; void main() { Array!(int) a; } //src\phobos\std\container.d(1660): Error: function core.stdc.stdlib.free (void* ptr) is not callable using argument types (int[]) //src\phobos\std\container.d(1660): Error: cannot implicitly convert expression ((*this._data)._payload) of type int[] to void* is it my fault? does anyone else have this problem?On 2010-06-15 09:49:29 +0200, Robert M. Münch said:Sorry for being slow on that. Currently TightArray (renamed to Array) uses hardcoded calls to malloc and free. I'd be glad to use a better design if one came along. AndreiHi, since std.container is now part of the DMD compiler and class allocators/deallocaters are no longer part of the language, the way to go now, as far as I understand now, it to use tightArray. So, how to use tightArray to allocate structs and classes from a specific memory pool? Will such allocations be under GC control or not? For example: How do I ensure that an allocation is done from a memory-mapped file area?Has noone a tipp for me how to make & use an own allocator?
Jun 16 2010
On Wed, 16 Jun 2010 10:04:05 +0200, Stephan wrote:Btw. I downloaded the new dmd(2047) and tried to use this new Array template. But it does not seem to work: import std.container; void main() { Array!(int) a; } //src\phobos\std\container.d(1660): Error: function core.stdc.stdlib.free (void* ptr) is not callable using argument types (int[]) //src\phobos\std\container.d(1660): Error: cannot implicitly convert expression ((*this._data)._payload) of type int[] to void* is it my fault? does anyone else have this problem?It's a bug (and a strange one at that). I've checked in a fix, see: http://d.puremagic.com/issues/show_bug.cgi?id=4327 -Lars
Jun 16 2010
On 16.06.2010 11:39, Lars T. Kyllingstad wrote:On Wed, 16 Jun 2010 10:04:05 +0200, Stephan wrote:thanks for that, i hope its in the next release.Btw. I downloaded the new dmd(2047) and tried to use this new Array template. But it does not seem to work: import std.container; void main() { Array!(int) a; } //src\phobos\std\container.d(1660): Error: function core.stdc.stdlib.free (void* ptr) is not callable using argument types (int[]) //src\phobos\std\container.d(1660): Error: cannot implicitly convert expression ((*this._data)._payload) of type int[] to void* is it my fault? does anyone else have this problem?It's a bug (and a strange one at that). I've checked in a fix, see: http://d.puremagic.com/issues/show_bug.cgi?id=4327 -Lars
Jun 16 2010
On 2010-06-16 08:59:47 +0200, Andrei Alexandrescu said:Sorry for being slow on that. Currently TightArray (renamed to Array) uses hardcoded calls to malloc and free. I'd be glad to use a better design if one came along.Hi Andrei, ok. At least it's a chart. I'm going to take a look and first try to replace malloc/free with my versions and than we can see how to make these functions replace-able at compile/run-time. --- Robert M. Münch http://www.robertmuench.de
Jun 16 2010
On 16/06/2010 10:50, Robert M. Münch wrote:On 2010-06-16 08:59:47 +0200, Andrei Alexandrescu said:HM'''' How to bring a (Tight)Array designed as memory watch dog and a fixed sized, but chunked, memory mapped file together. I am curious .. (to say the least)Sorry for being slow on that. Currently TightArray (renamed to Array) uses hardcoded calls to malloc and free. I'd be glad to use a better design if one came along.Hi Andrei, ok. At least it's a chart. I'm going to take a look and first try to replace malloc/free with my versions and than we can see how to make these functions replace-able at compile/run-time. --- Robert M. Münch http://www.robertmuench.de
Jun 16 2010
On 2010-06-16 15:33:40 +0200, BLS said:How to bring a (Tight)Array designed as memory watch dog and a fixed sized, but chunked, memory mapped file together. I am curious .. (to say the least)The idea is quite simple (not so much dependend on Array): - implement a memory-allocator and manager that manages the free space in a memory mapped file (MMF) - implement a based pointer type to have address independent pointers inside the MMF - provide a way to allocate data-structures using based pointers via this memory manager in the memory mapped file - use these data-structures at run-time The run-time objects will be persistent by default. The based pointer ensures that links between such objects are pesistent. The memory manager keeps track of the free areas and used areas of the MMF much like a file-system. As I don't want to mirror all D runtime stuff I'm seeking for a way to gently exchange/swap the normal GC memory allocator through a MMF allocator, without impacting the normal types, classes etc. -- Robert M. Münch http://www.robertmuench.de
Jun 16 2010