Idiomatic way to generate all possible values a static array of ubyte can have
Steven Schveighoffer via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Apr 2 11:32:03 PDT 2016
On 4/2/16 5:47 AM, jkpl wrote:
> gives: core.exception.OutOfMemoryError at src/core/exception.d(693): Memory
> allocation failed
>
>
>
Probably because randomCover needs to allocate a bool for all the
elements it has already covered, so you are allocating 32 * 4G bools.
How much RAM do you have? Note that D's GC is conservative, so false
pointers, especially for large arrays also can cause problems.
I'll note that even if it worked, this code will never complete in your
lifetime, or even your great great grandchild's lifetime. I don't
understand the point of doing this.
I'll also note that if you just want to test a *subset* of all the
possible inputs (given the length of time taken to test all these), you
probably want to change different elements each time through the loop.
Your code spends a long time testing the same elements in the first
slots. Given your test code is just looking at the first element, this
isn't very good test coverage.
I honestly think you are better off just generating random arrays, even
if it results in some overlap (unlikely to be relevant).
-Steve
More information about the Digitalmars-d-learn
mailing list