<div dir="ltr"><div dir="ltr">On Fri, Jan 15, 2021 at 8:20 AM dog2002 via Digitalmars-d-learn <<a href="mailto:digitalmars-d-learn@puremagic.com">digitalmars-d-learn@puremagic.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Friday, 15 January 2021 at 06:56:36 UTC, dog2002 wrote:<br>
> On Friday, 15 January 2021 at 06:33:55 UTC, Paul Backus wrote:<br>
>> On Friday, 15 January 2021 at 06:31:18 UTC, Paul Backus wrote:<br>
>>><br>
>>> You can save a little bit of memory here by allocating <br>
>>> tempBuffer on the stack:<br>
>>><br>
>>>     ubyte[512] tempBuffer;<br>
>>>     _inputFile.rawRead(tempBuffer[]); // note the explicit []<br>
>><br>
>> I made a mistake; this should be:<br>
>><br>
>>     ubyte[512] tempArray;<br>
>>     ubyte[] tempBuffer = _inputFile.rawRead(tempArray[]);<br>
>><br>
>> ...with the rest the same as your original version.<br>
><br>
> Thank you so much! It saves a lot of memory!<br>
><br>
> And one last question: why the application crashes, if I <br>
> allocate 1 MB array?<br>
><br>
>>ubyte[1024000] tempBuffer;<br>
<br>
Solved:<br>
<br>
ubyte[] tempBuffer = new ubyte[1024000];<br></blockquote><div><br></div><div>You can still use ubyte[1024000] tempBuffer; but you have to place it somewhere outside recursion or use a static</div><div>static ubyte[1024000] tempBuffer;<br></div></div></div>