Re: "Memory allocation failed" on big array

2022-07-20 Thread urned utt via Digitalmars-d-learn
Big thank. Switch to /bin64 and now works until full memory using.

Re: "Memory allocation failed" on big array

2022-07-20 Thread ryuukk_ via Digitalmars-d-learn
My guess is you are compiling to 32bit and the GC tries to reserve >4gb wich it can't, therefore out of memory Compiling to 64bit with: `dmd -m64 -run test.d` works no problem

"Memory allocation failed" on big array

2022-07-20 Thread urned utt via Digitalmars-d-learn
uot;%,3d", i), format("%,3d", dic.length)); } } ``` got an error: "processed line 32,000,000: 32,000,001 core.exception.OutOfMemoryError@src\core\lifetime.d(126): Memory allocation failed" app used is about 1.6 Gb, more than 4 stays free. 1. What is happened, w

Re: 2D arrays, slices and manual memory allocation

2022-02-24 Thread Nonobvious via Digitalmars-d-learn
On Friday, 25 February 2022 at 06:13:35 UTC, 9il wrote: On Friday, 25 February 2022 at 06:03:34 UTC, Nonobvious wrote: From [Go Your Own Way (Part Two: The Heap)](https://dlang.org/blog/2017/09/25/go-your-own-way-part-two-the-heap/): [...] http://mir-algorithm.libmir.org/mir_ndslice_allocati

Re: 2D arrays, slices and manual memory allocation

2022-02-24 Thread 9il via Digitalmars-d-learn
On Friday, 25 February 2022 at 06:03:34 UTC, Nonobvious wrote: From [Go Your Own Way (Part Two: The Heap)](https://dlang.org/blog/2017/09/25/go-your-own-way-part-two-the-heap/): [...] http://mir-algorithm.libmir.org/mir_ndslice_allocation.html#.stdcUninitSlice

2D arrays, slices and manual memory allocation

2022-02-24 Thread Nonobvious via Digitalmars-d-learn
From [Go Your Own Way (Part Two: The Heap)](https://dlang.org/blog/2017/09/25/go-your-own-way-part-two-the-heap/): `import core.stdc.stdlib;` `// Allocate a block of untyped bytes that can be managed` `// as a slice.` `void[] allocate(size_t size)` `{` `// malloc(0) is i

Re: std.zip expand: memory allocation failed

2021-10-27 Thread bauss via Digitalmars-d-learn
On Tuesday, 26 October 2021 at 13:43:36 UTC, Steven Schveighoffer wrote: On 10/26/21 2:32 AM, bauss wrote: On Monday, 25 October 2021 at 22:38:38 UTC, Imperatorn wrote: On Monday, 25 October 2021 at 20:50:40 UTC, Steven Schveighoffer wrote: On 10/24/21 8:00 AM, Selim Ozel wrote: It turns out

Re: std.zip expand: memory allocation failed

2021-10-26 Thread Imperatorn via Digitalmars-d-learn
On Tuesday, 26 October 2021 at 20:33:17 UTC, Steven Schveighoffer wrote: On 10/26/21 1:38 PM, Imperatorn wrote: That's the current implementation. No, that's the API. You cannot fix the implementation with that API and not end up allocating an array to hold the entire unzipped contents. Yo

Re: std.zip expand: memory allocation failed

2021-10-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/26/21 1:38 PM, Imperatorn wrote: That's the current implementation. No, that's the API. You cannot fix the implementation with that API and not end up allocating an array to hold the entire unzipped contents. You can't even decompress to a file, and then mmap those contents -- the ad

Re: std.zip expand: memory allocation failed

2021-10-26 Thread Imperatorn via Digitalmars-d-learn
On Tuesday, 26 October 2021 at 17:38:22 UTC, Imperatorn wrote: On Tuesday, 26 October 2021 at 13:43:36 UTC, Steven Schveighoffer wrote: On 10/26/21 2:32 AM, bauss wrote: On Monday, 25 October 2021 at 22:38:38 UTC, Imperatorn wrote: [...] Definitely not. It shouldn't use a lot of memory when

Re: std.zip expand: memory allocation failed

2021-10-26 Thread Imperatorn via Digitalmars-d-learn
On Tuesday, 26 October 2021 at 13:43:36 UTC, Steven Schveighoffer wrote: On 10/26/21 2:32 AM, bauss wrote: On Monday, 25 October 2021 at 22:38:38 UTC, Imperatorn wrote: On Monday, 25 October 2021 at 20:50:40 UTC, Steven Schveighoffer wrote: On 10/24/21 8:00 AM, Selim Ozel wrote: [...] Wait

Re: std.zip expand: memory allocation failed

2021-10-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/26/21 2:32 AM, bauss wrote: On Monday, 25 October 2021 at 22:38:38 UTC, Imperatorn wrote: On Monday, 25 October 2021 at 20:50:40 UTC, Steven Schveighoffer wrote: On 10/24/21 8:00 AM, Selim Ozel wrote: It turns out my computer was literally running out of memory as the file was getting u

Re: std.zip expand: memory allocation failed

2021-10-26 Thread Imperatorn via Digitalmars-d-learn
On Tuesday, 26 October 2021 at 06:32:21 UTC, bauss wrote: On Monday, 25 October 2021 at 22:38:38 UTC, Imperatorn wrote: On Monday, 25 October 2021 at 20:50:40 UTC, Steven Schveighoffer wrote: On 10/24/21 8:00 AM, Selim Ozel wrote: [...] Wait, x86 is 32-bit. Max address space is 4GB. So mayb

Re: std.zip expand: memory allocation failed

2021-10-25 Thread bauss via Digitalmars-d-learn
On Monday, 25 October 2021 at 22:38:38 UTC, Imperatorn wrote: On Monday, 25 October 2021 at 20:50:40 UTC, Steven Schveighoffer wrote: On 10/24/21 8:00 AM, Selim Ozel wrote: It turns out my computer was literally running out of memory as the file was getting unzipped. For some reason  to uncom

Re: std.zip expand: memory allocation failed

2021-10-25 Thread Imperatorn via Digitalmars-d-learn
On Monday, 25 October 2021 at 20:50:40 UTC, Steven Schveighoffer wrote: On 10/24/21 8:00 AM, Selim Ozel wrote: It turns out my computer was literally running out of memory as the file was getting unzipped. For some reason  to uncompress a 1-gig file with uncompressed size of 4-gig, Zip Archiv

Re: std.zip expand: memory allocation failed

2021-10-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/24/21 8:00 AM, Selim Ozel wrote: It turns out my computer was literally running out of memory as the file was getting unzipped. For some reason  to uncompress a 1-gig file with uncompressed size of 4-gig, Zip Archive of D-Lang tries to use more than 16 gig of RAM. I don't know why. Maybe

Re: std.zip expand: memory allocation failed

2021-10-25 Thread Selim Ozel via Digitalmars-d-learn
On Sunday, 24 October 2021 at 14:14:08 UTC, Imperatorn wrote: Create an issue and we can solve it Thanks. I opened an issue. https://issues.dlang.org/show_bug.cgi?id=22436

Re: std.zip expand: memory allocation failed

2021-10-24 Thread Imperatorn via Digitalmars-d-learn
On Sunday, 24 October 2021 at 12:00:39 UTC, Selim Ozel wrote: On Friday, 15 October 2021 at 20:41:36 UTC, Selim Ozel wrote: [...] It turns out my computer was literally running out of memory as the file was getting unzipped. For some reason to uncompress a 1-gig file with uncompressed size

Re: std.zip expand: memory allocation failed

2021-10-24 Thread Selim Ozel via Digitalmars-d-learn
has a solution? Memory mapping [2] previously solved some part of my issue but expand is still throwing memory allocation failure. Selim [1] https://dlang.org/phobos/std_zip.html [2] https://forum.dlang.org/thread/mfnleztnwrbgivjvz...@forum.dlang.org It turns out my computer was literally running o

Re: std.zip expand: memory allocation failed

2021-10-23 Thread Selim Ozel via Digitalmars-d-learn
Did you try the MmFile workaround? I did. I also pinpointed the problem, I use x86_mscoff to run dub and it's specific to that architecture selection. It's related to MapViewOfFileEx [1]. I still haven't found a way around it though. [1] https://stackoverflow.com/questions/12121843/mapview

Re: std.zip expand: memory allocation failed

2021-10-16 Thread Imperatorn via Digitalmars-d-learn
has a solution? Memory mapping [2] previously solved some part of my issue but expand is still throwing memory allocation failure. Selim [1] https://dlang.org/phobos/std_zip.html [2] https://forum.dlang.org/thread/mfnleztnwrbgivjvz...@forum.dlang.org Did you try the MmFile workaround?

std.zip expand: memory allocation failed

2021-10-15 Thread Selim Ozel via Digitalmars-d-learn
issue but expand is still throwing memory allocation failure. Selim [1] https://dlang.org/phobos/std_zip.html [2] https://forum.dlang.org/thread/mfnleztnwrbgivjvz...@forum.dlang.org

Re: Missing stacktrace on memory allocation failure

2021-06-02 Thread Mathias LANG via Digitalmars-d-learn
On Wednesday, 2 June 2021 at 17:52:12 UTC, mw wrote: On Thursday, 12 November 2020 at 13:16:21 UTC, Steven Schveighoffer wrote: On 11/12/20 4:22 AM, Per Nordlöw wrote: Why don't I get a stack trace on Memory allocation exceptions? In my case I only get: src/core/exception.d(647): [uni

Re: Missing stacktrace on memory allocation failure

2021-06-02 Thread mw via Digitalmars-d-learn
On Thursday, 12 November 2020 at 13:16:21 UTC, Steven Schveighoffer wrote: On 11/12/20 4:22 AM, Per Nordlöw wrote: Why don't I get a stack trace on Memory allocation exceptions? In my case I only get: src/core/exception.d(647): [unittest] Memory allocation f

Re: Memory allocation

2021-02-23 Thread David via Digitalmars-d-learn
On Wednesday, 24 February 2021 at 06:14:58 UTC, Imperatorn wrote: On Tuesday, 23 February 2021 at 19:44:39 UTC, David wrote: Not sure if `learn` is the right topic or not to post this.. I've been going through Bob Nystrom's "Crafting Interpreters" for a bit of fun and over the weekend put toge

Re: Memory allocation

2021-02-23 Thread Imperatorn via Digitalmars-d-learn
On Tuesday, 23 February 2021 at 19:44:39 UTC, David wrote: Not sure if `learn` is the right topic or not to post this.. I've been going through Bob Nystrom's "Crafting Interpreters" for a bit of fun and over the weekend put together a toy allocator in D - free and gc not yet done. It's single

Memory allocation

2021-02-23 Thread David via Digitalmars-d-learn
Not sure if `learn` is the right topic or not to post this.. I've been going through Bob Nystrom's "Crafting Interpreters" for a bit of fun and over the weekend put together a toy allocator in D - free and gc not yet done. It's single threaded and unsurprisingly faster than malloc for small ob

Re: Missing stacktrace on memory allocation failure

2020-11-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/12/20 4:22 AM, Per Nordlöw wrote: Why don't I get a stack trace on Memory allocation exceptions? In my case I only get: src/core/exception.d(647): [unittest] Memory allocation failed core.exception.OutOfMemoryError@src/core/exception.d(647): Memory allocation failed Certain e

Re: Missing stacktrace on memory allocation failure

2020-11-12 Thread Per Nordlöw via Digitalmars-d-learn
On Thursday, 12 November 2020 at 09:22:10 UTC, Per Nordlöw wrote: Why don't I get a stack trace on Memory allocation exceptions? Is it because the stack may be corrupted?

Missing stacktrace on memory allocation failure

2020-11-12 Thread Per Nordlöw via Digitalmars-d-learn
Why don't I get a stack trace on Memory allocation exceptions? In my case I only get: src/core/exception.d(647): [unittest] Memory allocation failed core.exception.OutOfMemoryError@src/core/exception.d(647): Memory allocation failed

Re: Memory allocation failed in CT

2019-07-13 Thread a11e99z via Digitalmars-d-learn
On Saturday, 13 July 2019 at 06:25:37 UTC, Andrey wrote: On Tuesday, 9 July 2019 at 19:04:53 UTC, Max Haughton wrote: Is this a 64 or 32 bit compiler? Also could you post the source code if possible? You could try "--DRT-gcopt=profile:1" druntime flag to see if the compiler is running out of

Re: Memory allocation failed in CT

2019-07-12 Thread Andrey via Digitalmars-d-learn
On Tuesday, 9 July 2019 at 19:04:53 UTC, Max Haughton wrote: Is this a 64 or 32 bit compiler? Also could you post the source code if possible? You could try "--DRT-gcopt=profile:1" druntime flag to see if the compiler is running out of memory for real Thanks for help. I solved my issue by re

Re: Memory allocation failed in CT

2019-07-09 Thread Max Haughton via Digitalmars-d-learn
Is this a 64 or 32 bit compiler? Also could you post the source code if possible? You could try "--DRT-gcopt=profile:1" druntime flag to see if the compiler is running out of memory for real

Re: Memory allocation failed in CT

2019-07-09 Thread Andrey via Digitalmars-d-learn
On Tuesday, 9 July 2019 at 17:59:24 UTC, Max Haughton wrote: On Tuesday, 9 July 2019 at 17:48:52 UTC, Andrey wrote: Hello, I have got a problem with compile-time calulations. I have some code generator that should create some long string of code during CT and after generation I mixin it. If I r

Re: Memory allocation failed in CT

2019-07-09 Thread Andrey via Digitalmars-d-learn
On Tuesday, 9 July 2019 at 17:59:24 UTC, Max Haughton wrote: On Tuesday, 9 July 2019 at 17:48:52 UTC, Andrey wrote: I in addition wrote "buffer.reserve(10 * 1014 * 1024);" and it also doesn't help.

Re: Memory allocation failed in CT

2019-07-09 Thread Max Haughton via Digitalmars-d-learn
On Tuesday, 9 July 2019 at 17:48:52 UTC, Andrey wrote: Hello, I have got a problem with compile-time calulations. I have some code generator that should create some long string of code during CT and after generation I mixin it. If I run it normally - in run time - then there is no error and I g

Memory allocation failed in CT

2019-07-09 Thread Andrey via Digitalmars-d-learn
run it in CT then I recieve an error: core.exception.OutOfMemoryError@core\exception.d(702): Memory allocation failed 0x7FF65A80BE73 0x7FF65A80BE73 0x7FF65A80BB46 0x7FF65A7FBA5C 0x7FF65A8035EC 0x7FF65A804311 0x7FF658BA733E 0x7FF658CC561F

Re: Closures and memory allocation

2019-06-22 Thread kinke via Digitalmars-d-learn
On Saturday, 22 June 2019 at 16:52:07 UTC, Anonymouse wrote: When entering the following function, does it allocate: 1. 0 times, because while there are closures defined, none is ever called? 2. 2 times, because there are closures over two variables? 3. 20 times, because there are 20 unique cl

Re: Closures and memory allocation

2019-06-22 Thread Cym13 via Digitalmars-d-learn
On Saturday, 22 June 2019 at 19:26:13 UTC, Cym13 wrote: On Saturday, 22 June 2019 at 16:52:07 UTC, Anonymouse wrote: [...] Clearly this is a good time for you to learn about the tools D offers to profile allocations. There is the --profile=gc DMD argument that you can use but here there's so

Re: Closures and memory allocation

2019-06-22 Thread Cym13 via Digitalmars-d-learn
On Saturday, 22 June 2019 at 16:52:07 UTC, Anonymouse wrote: I'm looking into why my thing does so many memory allocations. Profiling with kcachegrind shows _d_allocmemory being called upon entering a certain function, lots and lots of times. It's a function that receives concurrency messages,

Closures and memory allocation

2019-06-22 Thread Anonymouse via Digitalmars-d-learn
I'm looking into why my thing does so many memory allocations. Profiling with kcachegrind shows _d_allocmemory being called upon entering a certain function, lots and lots of times. It's a function that receives concurrency messages, so it contains nested functions that close over local variab

Re: Does to!(string)(char[]) do any memory allocation on conversion?

2017-12-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, December 25, 2017 15:00:19 aliak via Digitalmars-d-learn wrote: > On Monday, 25 December 2017 at 14:12:32 UTC, Marc wrote: > > Does to!(string)(char[]) do any memory allocation on conversion > > or is this similar to a cast or what else? > > As said it ca

Re: Does to!(string)(char[]) do any memory allocation on conversion?

2017-12-25 Thread aliak via Digitalmars-d-learn
On Monday, 25 December 2017 at 14:12:32 UTC, Marc wrote: Does to!(string)(char[]) do any memory allocation on conversion or is this similar to a cast or what else? As said it calls idup, which calls _trustedDup which seems to call _dup which does memory allocation -> https://github.com/dl

Re: Does to!(string)(char[]) do any memory allocation on conversion?

2017-12-25 Thread Temtaime via Digitalmars-d-learn
On Monday, 25 December 2017 at 14:37:01 UTC, Mengu wrote: On Monday, 25 December 2017 at 14:12:32 UTC, Marc wrote: Does to!(string)(char[]) do any memory allocation on conversion or is this similar to a cast or what else? yes, it is allocating memory. you can test such cases with @nogc [0

Re: Does to!(string)(char[]) do any memory allocation on conversion?

2017-12-25 Thread Mengu via Digitalmars-d-learn
On Monday, 25 December 2017 at 14:12:32 UTC, Marc wrote: Does to!(string)(char[]) do any memory allocation on conversion or is this similar to a cast or what else? yes, it is allocating memory. you can test such cases with @nogc [0]. you can get a char[] via .dup of a string and then you

Re: Does to!(string)(char[]) do any memory allocation on conversion?

2017-12-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 25 December 2017 at 14:37:01 UTC, Mengu wrote: yes, it is allocating memory. you can test such cases with @nogc [0]. nogc is really conservative and thus gives a lot of false positives. I'd just compare instr.ptr is outstr.ptr here and see if it changes (it will tho)

Re: Does to!(string)(char[]) do any memory allocation on conversion?

2017-12-25 Thread Temtaime via Digitalmars-d-learn
On Monday, 25 December 2017 at 14:12:32 UTC, Marc wrote: Does to!(string)(char[]) do any memory allocation on conversion or is this similar to a cast or what else? It is translated to idup. So yes, it allocates memory.

Does to!(string)(char[]) do any memory allocation on conversion?

2017-12-25 Thread Marc via Digitalmars-d-learn
Does to!(string)(char[]) do any memory allocation on conversion or is this similar to a cast or what else?

Re: DMD [-O flag] vs. [memory allocation in a synchronized class]

2017-06-09 Thread realhet via Digitalmars-d-learn
On Thursday, 8 June 2017 at 17:39:41 UTC, Ivan Kazmenko wrote: Reported: https://issues.dlang.org/show_bug.cgi?id=17481 Thank You!

Re: DMD [-O flag] vs. [memory allocation in a synchronized class]

2017-06-08 Thread Ivan Kazmenko via Digitalmars-d-learn
On Thursday, 8 June 2017 at 15:35:06 UTC, Ivan Kazmenko wrote: Perhaps a regression should be filed, or searched for, at issues.dlang.org. I can do it, but not right now, and would be glad if someone beats me to it. Reported: https://issues.dlang.org/show_bug.cgi?id=17481

Re: DMD [-O flag] vs. [memory allocation in a synchronized class]

2017-06-08 Thread Ivan Kazmenko via Digitalmars-d-learn
On Thursday, 8 June 2017 at 11:41:40 UTC, realhet wrote: I've managed to narrow the problem even more: //win32 dmd -O class Obj{ synchronized void trigger(){ new ubyte[1]; } } void main(){ auto k = new shared Obj; k.trigger; } This time I got a more sophisticated error message: object.

Re: DMD [-O flag] vs. [memory allocation in a synchronized class]

2017-06-08 Thread realhet via Digitalmars-d-learn
I've managed to narrow the problem even more: //win32 dmd -O class Obj{ synchronized void trigger(){ new ubyte[1]; } } void main(){ auto k = new shared Obj; k.trigger; } This time I got a more sophisticated error message: object.Error@(0): Access Violation 0x7272456D in

Re: DMD [-O flag] vs. [memory allocation in a synchronized class]

2017-06-08 Thread ketmar via Digitalmars-d-learn
realhet wrote: On Thursday, 8 June 2017 at 10:48:41 UTC, ketmar wrote: worksforme with -O, and with -O -inline. I forgot to mention, that I'm generating win32 output. DMD32 D Compiler v2.074.0 mine: GNU/Linux, 32 bit, dmd git HEAD.

Re: DMD [-O flag] vs. [memory allocation in a synchronized class]

2017-06-08 Thread realhet via Digitalmars-d-learn
On Thursday, 8 June 2017 at 10:48:41 UTC, ketmar wrote: worksforme with -O, and with -O -inline. I forgot to mention, that I'm generating win32 output. DMD32 D Compiler v2.074.0

Re: DMD [-O flag] vs. [memory allocation in a synchronized class]

2017-06-08 Thread ketmar via Digitalmars-d-learn
worksforme with -O, and with -O -inline.

DMD [-O flag] vs. [memory allocation in a synchronized class]

2017-06-08 Thread realhet via Digitalmars-d-learn
Hi, This code works well with the unoptimized compilation with DMD. import std.array; synchronized class Obj{ private int[] arr; void trigger(){ arr.length += 1; } } void main(){ auto k = new shared Obj; k.trigger; } And when I use the -O option, it shows the following error in the t

Re: Memory Allocation

2017-03-30 Thread Enigma via Digitalmars-d-learn
On Thursday, 30 March 2017 at 11:22:05 UTC, Gary Willoughby wrote: On Wednesday, 29 March 2017 at 19:19:48 UTC, Enigma wrote: I have a memory buffer allocated using different methods. It is simply a pointer and a size. I would like to be able to manage this buffer by treating it as a memory p

Re: Memory Allocation

2017-03-30 Thread Enigma via Digitalmars-d-learn
On Wednesday, 29 March 2017 at 23:26:04 UTC, H. S. Teoh wrote: On Wed, Mar 29, 2017 at 11:01:12PM +, Enigma via Digitalmars-d-learn wrote: On Wednesday, 29 March 2017 at 21:36:14 UTC, Petar Kirov [ZombineDev] wrote: > [...] But these seem to require passing a mallocator. I simply want to

Re: Memory Allocation

2017-03-30 Thread Gary Willoughby via Digitalmars-d-learn
On Wednesday, 29 March 2017 at 19:19:48 UTC, Enigma wrote: I have a memory buffer allocated using different methods. It is simply a pointer and a size. I would like to be able to manage this buffer by treating it as a memory pool or heap. I think I can use allocators to do this but not sure h

Re: Memory Allocation

2017-03-29 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Mar 29, 2017 at 11:01:12PM +, Enigma via Digitalmars-d-learn wrote: > On Wednesday, 29 March 2017 at 21:36:14 UTC, Petar Kirov [ZombineDev] wrote: > > On Wednesday, 29 March 2017 at 19:19:48 UTC, Enigma wrote: > > > [...] > > > > It looks like you are looking for this: > > http://dlang

Re: Memory Allocation

2017-03-29 Thread Enigma via Digitalmars-d-learn
On Wednesday, 29 March 2017 at 21:36:14 UTC, Petar Kirov [ZombineDev] wrote: On Wednesday, 29 March 2017 at 19:19:48 UTC, Enigma wrote: [...] It looks like you are looking for this: http://dlang.org/phobos-prerelease/std_experimental_allocator_building_blocks_region.html. But these seem to

Re: Memory Allocation

2017-03-29 Thread via Digitalmars-d-learn
On Wednesday, 29 March 2017 at 19:19:48 UTC, Enigma wrote: I have a memory buffer allocated using different methods. It is simply a pointer and a size. I would like to be able to manage this buffer by treating it as a memory pool or heap. I think I can use allocators to do this but not sure h

Re: Memory Allocation

2017-03-29 Thread Faux Amis via Digitalmars-d-learn
On 2017-03-29 23:30, Faux Amis wrote: On 2017-03-29 21:19, Enigma wrote: I have a memory buffer allocated using different methods. It is simply a pointer and a size. Can you maybe just tread it like an array and slice it for allocation? *treat*

Re: Memory Allocation

2017-03-29 Thread Faux Amis via Digitalmars-d-learn
On 2017-03-29 21:19, Enigma wrote: I have a memory buffer allocated using different methods. It is simply a pointer and a size. Can you maybe just tread it like an array and slice it for allocation?

Memory Allocation

2017-03-29 Thread Enigma via Digitalmars-d-learn
I have a memory buffer allocated using different methods. It is simply a pointer and a size. I would like to be able to manage this buffer by treating it as a memory pool or heap. I think I can use allocators to do this but not sure how. Effectively I want something like new or malloc but it

Re: Memory allocation failed. Why?

2016-11-23 Thread MGW via Digitalmars-d-learn
On Tuesday, 22 November 2016 at 15:53:39 UTC, Steven Schveighoffer wrote: On 11/21/16 11:53 AM, ag0aep6g wrote: Thank you very much for explaining such a difficult and slippery situation.

Re: Memory allocation failed. Why?

2016-11-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/21/16 11:53 AM, ag0aep6g wrote: On Monday, 21 November 2016 at 16:37:32 UTC, Kagamin wrote: Anything in .data and .bss sections and stack. See https://issues.dlang.org/show_bug.cgi?id=15723 Ok, not an actual reference then, but a false pointer. Yes. 100 million bytes is 1/40 of all add

Re: Memory allocation failed. Why?

2016-11-21 Thread thedeemon via Digitalmars-d-learn
On Sunday, 20 November 2016 at 17:47:50 UTC, MGW wrote: core.exception.OutOfMemoryError@src\core\exception.d(693): Memory allocation failed Simple program and error. Why? Windows 7 (32) dmd 2.072.0 Making a 100 million bytes array by appending one byte at

Re: Memory allocation failed. Why?

2016-11-21 Thread ag0aep6g via Digitalmars-d-learn
On Monday, 21 November 2016 at 16:37:32 UTC, Kagamin wrote: Anything in .data and .bss sections and stack. See https://issues.dlang.org/show_bug.cgi?id=15723 Ok, not an actual reference then, but a false pointer.

Re: Memory allocation failed. Why?

2016-11-21 Thread Kagamin via Digitalmars-d-learn
On Monday, 21 November 2016 at 11:22:40 UTC, ag0aep6g wrote: Who could "someone" be? It's a self-contained example, and buf doesn't leave the test function. Anything in .data and .bss sections and stack. See https://issues.dlang.org/show_bug.cgi?id=15723 As for GC compaction: https://issues

Re: Memory allocation failed. Why?

2016-11-21 Thread ag0aep6g via Digitalmars-d-learn
On 11/21/2016 08:27 AM, Stefan Koch wrote: Someone could still be hanging on to an old Reference of buf. Who could "someone" be? It's a self-contained example, and buf doesn't leave the test function.

Re: Memory allocation failed. Why?

2016-11-20 Thread Stefan Koch via Digitalmars-d-learn
On Monday, 21 November 2016 at 06:45:04 UTC, ag0aep6g wrote: On 11/21/2016 07:36 AM, Stefan Koch wrote: On Monday, 21 November 2016 at 03:58:00 UTC, MGW wrote: On Sunday, 20 November 2016 at 18:58:04 UTC, Basile B. wrote: On Sunday, 20 November 2016 at 17:47:50 UTC, MGW wrote: [...] [...] Y

Re: Memory allocation failed. Why?

2016-11-20 Thread ag0aep6g via Digitalmars-d-learn
On 11/21/2016 07:36 AM, Stefan Koch wrote: On Monday, 21 November 2016 at 03:58:00 UTC, MGW wrote: On Sunday, 20 November 2016 at 18:58:04 UTC, Basile B. wrote: On Sunday, 20 November 2016 at 17:47:50 UTC, MGW wrote: import core.sys.windows.windows: MessageBoxA; void test() { for(int i; i

Re: Memory allocation failed. Why?

2016-11-20 Thread Stefan Koch via Digitalmars-d-learn
;.ptr, 0); } void main() { test(); MessageBoxA(null, "--The end--".ptr, "".ptr, 0); } core.exception.OutOfMemoryError@src\core\exception.d(693): Memory allocation failed This short program doesn't work at Windows 32. Why GC do

Re: Memory allocation failed. Why?

2016-11-20 Thread MGW via Digitalmars-d-learn
eBoxA(null, "--The end--".ptr, "".ptr, 0); } core.exception.OutOfMemoryError@src\core\exception.d(693): Memory allocation failed This short program doesn't work at Windows 32. Why GC doesn't release memory in case of its shortage in Windows! This is bug?

Re: Memory allocation failed. Why?

2016-11-20 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 20 November 2016 at 18:58:04 UTC, Basile B. wrote: On Sunday, 20 November 2016 at 17:47:50 UTC, MGW wrote: [...] For me there's no exception. Maybe the GC is poluted. Try to add this after each iteration in the first test loop: import core.memory: GC; GC.collect()

Re: Memory allocation failed. Why?

2016-11-20 Thread Basile B. via Digitalmars-d-learn
} core.exception.OutOfMemoryError@src\core\exception.d(693): Memory allocation failed Simple program and error. Why? Windows 7 (32) dmd 2.072.0 For me there's no exception. Maybe the GC is poluted. Try to add this after each iteration in the first test lo

Memory allocation failed. Why?

2016-11-20 Thread MGW via Digitalmars-d-learn
buf; // if ON - then memory delete in step } MessageBoxA(null, "--off for--".ptr, "".ptr, 0); } void main() { test(); MessageBoxA(null, "--The end--".ptr, "".ptr, 0); } core.exception.OutOfMemo

Re: What happens if memory allocation fails?

2016-02-20 Thread Chris Wright via Digitalmars-d-learn
On Sat, 20 Feb 2016 16:58:02 +, Adam D. Ruppe wrote: > On Saturday, 20 February 2016 at 14:21:28 UTC, tcak wrote: >> What happens if memory allocation fails with "new" keyword? > > Be aware that memory allocation might never actually fail. It really > dep

Re: What happens if memory allocation fails?

2016-02-20 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 20 February 2016 at 14:21:28 UTC, tcak wrote: What happens if memory allocation fails with "new" keyword? Be aware that memory allocation might never actually fail. It really depends on the operating system. But if it did fail, it would throw OutOfMemoryE

Re: What happens if memory allocation fails?

2016-02-20 Thread Kagamin via Digitalmars-d-learn
Currently it crashes: https://issues.dlang.org/show_bug.cgi?id=1180

What happens if memory allocation fails?

2016-02-20 Thread tcak via Digitalmars-d-learn
This is not easy to try. So I need ask, maybe someone has experienced. What happens if memory allocation fails with "new" keyword? Does it throw an exception? throwable? All I want is to be able to catch OutOfMemory event, and take other steps based on that.

Re: C string to D without memory allocation?

2015-12-21 Thread Marc Schütz via Digitalmars-d-learn
On Monday, 21 December 2015 at 09:46:58 UTC, Shriramana Sharma wrote: Jonathan M Davis via Digitalmars-d-learn wrote: If it isn't, all that means is that the array's capacity will be 0, so it's going to have to reallocate So it's safe to return a string produced by fromStringz without having

Re: C string to D without memory allocation?

2015-12-21 Thread Shriramana Sharma via Digitalmars-d-learn
Jonathan M Davis via Digitalmars-d-learn wrote: > If it isn't, all that means is that the > array's capacity will be 0, so it's going to have to reallocate So it's safe to return a string produced by fromStringz without having to worry that the user would append to it? Then why is it marked @sy

Re: C string to D without memory allocation?

2015-12-21 Thread Jakob Ovrum via Digitalmars-d-learn
On Monday, 21 December 2015 at 08:35:22 UTC, Jonathan M Davis wrote: There's also fromStringz that Jakob suggests using elsewhere in this thread, but that really just boils down to return cString ? cString[0 .. strlen(cString)] : null; So, using that over simply slicing is primarily for d

Re: C string to D without memory allocation?

2015-12-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, December 21, 2015 18:39:32 Rikki Cattermole via Digitalmars-d-learn wrote: > size_t strLen = ...; > char* ptr = ...; > > string myCString = cast(string)ptr[0 .. strLen]; > > I can't remember if it will include the null terminator or not, but if > it does just decrease strLen by 1. Cast

Re: C string to D without memory allocation?

2015-12-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, December 21, 2015 05:43:59 Jakob Ovrum via Digitalmars-d-learn wrote: > On Monday, 21 December 2015 at 05:41:31 UTC, Shriramana Sharma > wrote: > > Rikki Cattermole wrote: > > > >> string myCString = cast(string)ptr[0 .. strLen]; > > > > Thanks but does this require that one doesn't atte

Re: C string to D without memory allocation?

2015-12-20 Thread Jakob Ovrum via Digitalmars-d-learn
On Monday, 21 December 2015 at 06:00:45 UTC, Shriramana Sharma wrote: I suppose what you mean is, the onus of guaranteeing that const(char)* refers to a null-terminated string is upon the person calling the to! function? Yes I understand, and Phobos documentation does say that using a pointer f

Re: C string to D without memory allocation?

2015-12-20 Thread Shriramana Sharma via Digitalmars-d-learn
Jakob Ovrum wrote: > Use std.string.fromStringz. to!string assumes that pointers to > characters are null-terminated strings which is not safe or > general I suppose what you mean is, the onus of guaranteeing that const(char)* refers to a null-terminated string is upon the person calling the to

Re: C string to D without memory allocation?

2015-12-20 Thread Jakob Ovrum via Digitalmars-d-learn
On Monday, 21 December 2015 at 05:39:32 UTC, Rikki Cattermole wrote: size_t strLen = ...; char* ptr = ...; string myCString = cast(string)ptr[0 .. strLen]; I can't remember if it will include the null terminator or not, but if it does just decrease strLen by 1. Strings from C libraries shoul

Re: C string to D without memory allocation?

2015-12-20 Thread Jakob Ovrum via Digitalmars-d-learn
On Monday, 21 December 2015 at 05:43:04 UTC, Rikki Cattermole wrote: On 21/12/15 6:41 PM, Shriramana Sharma wrote: Rikki Cattermole wrote: string myCString = cast(string)ptr[0 .. strLen]; Thanks but does this require that one doesn't attempt to append to the returned string using ~= or such

Re: C string to D without memory allocation?

2015-12-20 Thread Shriramana Sharma via Digitalmars-d-learn
Rikki Cattermole wrote: > string myCString = cast(string)ptr[0 .. strLen]; Thanks but does this require that one doesn't attempt to append to the returned string using ~= or such? In which case it is not safe, right? -- Shriramana Sharma, Penguin #395953

Re: C string to D without memory allocation?

2015-12-20 Thread Rikki Cattermole via Digitalmars-d-learn
On 21/12/15 6:41 PM, Shriramana Sharma wrote: Rikki Cattermole wrote: string myCString = cast(string)ptr[0 .. strLen]; Thanks but does this require that one doesn't attempt to append to the returned string using ~= or such? In which case it is not safe, right? Correct, ~= should only be use

Re: C string to D without memory allocation?

2015-12-20 Thread Jakob Ovrum via Digitalmars-d-learn
On Monday, 21 December 2015 at 05:41:31 UTC, Shriramana Sharma wrote: Rikki Cattermole wrote: string myCString = cast(string)ptr[0 .. strLen]; Thanks but does this require that one doesn't attempt to append to the returned string using ~= or such? In which case it is not safe, right? Grow

Re: C string to D without memory allocation?

2015-12-20 Thread Jakob Ovrum via Digitalmars-d-learn
On Monday, 21 December 2015 at 05:34:07 UTC, Shriramana Sharma wrote: Hello. I have the following code: import std.stdio, std.conv; extern(C) const(char) * textAttrN(const (char) * specString, size_t n); string textAttr(const(char)[] specString) { const(char) * ptr = textAttrN(specString.p

Re: C string to D without memory allocation?

2015-12-20 Thread Rikki Cattermole via Digitalmars-d-learn
On 21/12/15 6:34 PM, Shriramana Sharma wrote: Hello. I have the following code: import std.stdio, std.conv; extern(C) const(char) * textAttrN(const (char) * specString, size_t n); string textAttr(const(char)[] specString) { const(char) * ptr = textAttrN(specString.ptr, specString.length);

C string to D without memory allocation?

2015-12-20 Thread Shriramana Sharma via Digitalmars-d-learn
Hello. I have the following code: import std.stdio, std.conv; extern(C) const(char) * textAttrN(const (char) * specString, size_t n); string textAttr(const(char)[] specString) { const(char) * ptr = textAttrN(specString.ptr, specString.length); writeln(ptr); return to!string(ptr); } voi

some memory allocation/GC benchmarks here - fwiw

2015-04-01 Thread Laeeth Isharc via Digitalmars-d-learn
(not translated into D yet) http://blog.mgm-tp.com/2013/12/benchmarking-g1-and-other-java-7-garbage-collectors/ http://www.mm-net.org.uk/resources/benchmarks.html http://www.ccs.neu.edu/home/will/GC/sourcecode.html http://yoda.arachsys.com/csharp/benchmark.html it's possible we already have bett

Re: How to get nogc to work with manual memory allocation

2014-09-05 Thread via Digitalmars-d-learn
On Friday, 5 September 2014 at 06:43:56 UTC, monarch_dodra wrote: On Sunday, 24 August 2014 at 09:29:53 UTC, Jacob Carlborg wrote: On 2014-08-24 10:03, Bienlein wrote: I have omitted the code for the TestClass class to save space. Problem is that the compiler outputs this: Error: @nogc funct

Re: How to get nogc to work with manual memory allocation

2014-09-04 Thread monarch_dodra via Digitalmars-d-learn
On Sunday, 24 August 2014 at 09:29:53 UTC, Jacob Carlborg wrote: On 2014-08-24 10:03, Bienlein wrote: I have omitted the code for the TestClass class to save space. Problem is that the compiler outputs this: Error: @nogc function 'main.nogcNew!(TestClass, ).nogcNew' cannot call non-@nogc fu

  1   2   >