Hello. I want to try use D without GC and I'm not sure what I do
all right.
import core.memory;
version( gcdis ) enum gc_disable = true;
else enum gc_disable = false;
class Foo
{
byte[][] buf;
this()
{
foreach( i; 0 .. 32 )
buf ~= new byte[]( 65536 *
On 7/06/2015 10:16 p.m., Oleg B wrote:
Hello. I want to try use D without GC and I'm not sure what I do all right.
import core.memory;
version( gcdis ) enum gc_disable = true;
else enum gc_disable = false;
class Foo
{
byte[][] buf;
this()
{
foreach( i; 0 ..
No just reserve some memory and preallocate the buffer you want
before using it. It'll be a lot faster and cheaper.
I know, it's only for test.
You shouldn't be using delete or new for that matter.
You should be using malloc + free. And emplace.
auto myalloc(T)( size_t count )
{
struct Im
On Sunday, 7 June 2015 at 16:25:29 UTC, Oleg B wrote:
auto myalloc(T)( size_t count )
{
struct Impl{ size_t len; void* ptr; }
union Wrap { Impl impl; T[] arr; }
auto ret = Wrap( Impl( count, calloc( count, T.sizeof ) )
).arr;
enforce( ret.ptr !is null );
return ret;
}
No
On Sunday, 7 June 2015 at 10:23:22 UTC, Rikki Cattermole wrote:
Don't worry about collecting at the end. The OS will clean up
the app no matter what.
Actually D runtime will also do a collection before exiting. This
is why it shows "Number of collections: 2" above. One triggered
manually, on
On Sunday, 7 June 2015 at 10:16:36 UTC, Oleg B wrote:
Hello. I want to try use D without GC and I'm not sure what I
do all right.
You may want to take a look at this Wiki page. It has several
patterns managing memory without the GC:
http://wiki.dlang.org/Memory_Management
Mike
On Sunday, 7 June 2015 at 16:25:29 UTC, Oleg B wrote:
No just reserve some memory and preallocate the buffer you
want before using it. It'll be a lot faster and cheaper.
I know, it's only for test.
You shouldn't be using delete or new for that matter.
You should be using malloc + free. And emp
I guess you should follow andrei's post about new allocators!
Can you get link to this post?
I guess you should follow andrei's post about new allocators!
Did you mean this article
http://wiki.dlang.org/Memory_Management#Explicit_Class_Instance_Allocation
?
On Monday, 8 June 2015 at 12:24:56 UTC, Oleg B wrote:
I guess you should follow andrei's post about new allocators!
Can you get link to this post?
These are some of his posts:
http://forum.dlang.org/thread/mku0n4$s35$1...@digitalmars.com
http://forum.dlang.org/thread/mkl1eh$1mdl$2...@digital
On Monday, 8 June 2015 at 13:37:40 UTC, Marc Schütz wrote:
On Monday, 8 June 2015 at 12:24:56 UTC, Oleg B wrote:
I guess you should follow andrei's post about new allocators!
Can you get link to this post?
These are some of his posts:
http://forum.dlang.org/thread/mku0n4$s35$1...@digitalmar
On Monday, 8 June 2015 at 20:11:31 UTC, Oleg B wrote:
On Monday, 8 June 2015 at 13:37:40 UTC, Marc Schütz wrote:
On Monday, 8 June 2015 at 12:24:56 UTC, Oleg B wrote:
I guess you should follow andrei's post about new allocators!
Can you get link to this post?
These are some of his posts:
h
12 matches
Mail list logo