Re: allocate() and free()
Aku writes:
> -- [ repeat(' ', 10485760) uses 80 MB
> -- of memory!!! ]
I don't trust your method of determining free memory.
The call to repeat() above only uses 4x1Mb = 4Mb not 80Mb.
It's also possible that malloc() will ask for *slightly* more than
4Mb.
> I can free memory that is used in VB, why not in Euphoria?
I don't trust your measurements. The O/S call,
GlobalMemoryStatus(), requires you to set the first field
in a structure before making the call, something you
don't bother to do. It also says the values returned
can change even if *nothing* happens in your program
between calls - i.e. the external world can change these
numbers independent of your program.
Euphoria is managing memory in a reasonable way.
A lot of people assume that memory will be given back
to the O/S when it's freed. This is a popular misconception.
Even if it were possible to do this, it would be highly inefficient
to call the O/S with every call to free().
Be thankful you aren't using Java. The last time I looked,
Sun's Java was pre-allocating 16Mb before any tiny Java
program even started running!
Regards,
Rob Craig
Rapid Deployment Software
http://www.RapidEuphoria.com
|
Not Categorized, Please Help
|
|