[fpc-pascal] TFileStream.WriteBuffer() and RAM used ?

Michael Van Canneyt michael at freepascal.org
Sat Dec 10 15:56:34 CET 2016

On Sat, 10 Dec 2016, fredvs wrote:

> Hello Michael.
>> The RAM increase is normal...
> OK, I was thinking that too but... is it normal that the app crash if there
> are no more ram available ?
> If so, how to know how many ram is disponible (and then create a temporally
> file if too few).

There is no reliable way, the OS these days allocates as needed and starts swapping.

> One minute of recording stereo 16 bit is +- 10 megas.
>> And where do you free DataRec ?
> When the recording stops (at end of WriteWave() procedure).


> Thanks for helping.

I would write as soon as some hardcoded size limit is reached.

As an alternative, you could try to work with threads: one thread reads the
input and stores it in blocks of memory, and a second thread writes the
blocks as soon as it detects a new block.

But that is a more difficult architecture...


More information about the fpc-pascal mailing list