digitalmars.D - Stack + Heap allocation store
- Per =?UTF-8?B?Tm9yZGzDtnc=?= (8/8) Jul 27 2020 Walter's talk on DConf 2019 talks about a favorite design pattern
- Steven Schveighoffer (9/21) Jul 27 2020 Doesn't std.experimental.allocator provide such capabilities?
- Mathias LANG (4/12) Jul 27 2020 There's
- Per =?UTF-8?B?Tm9yZGzDtnc=?= (2/5) Jul 28 2020 Which are its issues?
- Per =?UTF-8?B?Tm9yZGzDtnc=?= (4/5) Jul 28 2020 I looked the code. I see what you mean now.
- Ben Jones (3/8) Jul 28 2020 Not sure it's bulletproof, but I have something like that here:
- Paul Backus (2/10) Jul 28 2020 http://dpldocs.info/experimental-docs/std.experimental.allocator.showcas...
Walter's talk on DConf 2019 talks about a favorite design pattern of his - a hybrid approach to memory allocation. A store first allocates on the stack and then when it grows too large it moves the data to a heap allocation (array). I know such a struct is not hard to write but I ask anyway to collect advice on writing it. Does Phobos have anything like that? What about code.dlang.org?
Jul 27 2020
On 7/27/20 7:50 PM, Per Nordlöw wrote:Walter's talk on DConf 2019 talks about a favorite design pattern of his - a hybrid approach to memory allocation. A store first allocates on the stack and then when it grows too large it moves the data to a heap allocation (array). I know such a struct is not hard to write but I ask anyway to collect advice on writing it. Does Phobos have anything like that? What about code.dlang.org?Doesn't std.experimental.allocator provide such capabilities? I think you can combine a Region allocator with a Fallback heap allocator. In that case, all you need is something that will realloc when it needs more data, and the allocator will handle the details. But depending on how movable the item needs to be, you may want to allocate it directly in the struct itself, and have a flag which indicates to use a pointer instead (like the small string optimization). -Steve
Jul 27 2020
On Monday, 27 July 2020 at 23:50:13 UTC, Per Nordlöw wrote:Walter's talk on DConf 2019 talks about a favorite design pattern of his - a hybrid approach to memory allocation. A store first allocates on the stack and then when it grows too large it moves the data to a heap allocation (array). I know such a struct is not hard to write but I ask anyway to collect advice on writing it. Does Phobos have anything like that? What about code.dlang.org?There's https://github.com/dlang/phobos/blob/master/std/internal/scopebuffer.d However, beware, here be dragons.
Jul 27 2020
On Tuesday, 28 July 2020 at 04:16:51 UTC, Mathias LANG wrote:There's https://github.com/dlang/phobos/blob/master/std/internal/scopebuffer.d However, beware, here be dragons.Which are its issues?
Jul 28 2020
On Tuesday, 28 July 2020 at 14:02:55 UTC, Per Nordlöw wrote:Which are its issues?I looked the code. I see what you mean now. Seems like a template param for initial size is preferred over the unsafe buffer pointer to the ctor.
Jul 28 2020
On Tuesday, 28 July 2020 at 14:19:25 UTC, Per Nordlöw wrote:On Tuesday, 28 July 2020 at 14:02:55 UTC, Per Nordlöw wrote:Not sure it's bulletproof, but I have something like that here: https://github.com/benjones/dtriangulate/blob/master/source/dtriangulate/ssoVector.dWhich are its issues?I looked the code. I see what you mean now. Seems like a template param for initial size is preferred over the unsafe buffer pointer to the ctor.
Jul 28 2020
On Monday, 27 July 2020 at 23:50:13 UTC, Per Nordlöw wrote:Walter's talk on DConf 2019 talks about a favorite design pattern of his - a hybrid approach to memory allocation. A store first allocates on the stack and then when it grows too large it moves the data to a heap allocation (array). I know such a struct is not hard to write but I ask anyway to collect advice on writing it. Does Phobos have anything like that? What about code.dlang.org?http://dpldocs.info/experimental-docs/std.experimental.allocator.showcase.StackFront.html
Jul 28 2020