Konstantin Münning wrote: >>And in all cases, the program will still crash occasionally because it >>runs out of memory in certain cases, because the check and the >>allocation do not happen atomically. You can't put something into the >>standard Run Time Library which works "most of the time, except under >>heavy load". Imagine reading the docs and encountering that comment, >>you'd immediately start wondering how many more procedures there are >>which work "most of the time". > > > Most programs work most of the time except under heavy load. That's not > a good argument. Most small (C) programs don't do any memory
Pascal is not C ;) > availability checks at all. Look at most of the command line tools on > any OS ;-). Of course I would like to have any code behave perfect under > any condition but it has always been a tradeoff between effort > (=expense) and impact. But when there is no memory left and you need > some you can't behave perfect. Please let it be the programmers choice > what to do and how to handle this. A compiler should be providing the > means, not taking them away. Anybody writing a program knows that there > may be flaws. A warning (with an advice how to make it better) should > still be the best for this. > > By the way, I've found the following code in compiler/cclasses.pas when > I searched for the whereabouts of maxavail/memavail and there were some > more like this in the sources: > > {$ifdef HASGETHEAPSTATUS} > status:=GetFPCHeapStatus; > startmem:=status.CurrHeapUsed; > {$else HASGETHEAPSTATUS} > startmem:=memavail; > {$endif HASGETHEAPSTATUS} > > I'm not sure if I understand it right as GetHeapStatus is not documented > well (I've found no reference for the meaning of the fields of the > returned record) but it seems that someone repaced here memavail with > another code which does about the same and has therefore the same flaw. It has been moved to heap status which contains more info which also reliable on multitasking systems. > > I would hapily contribute the code for a better MemAvail/MaxAvail > function if that's the problem. I would like to be able to use the > latest compiler which now I definitely can't See below. > as I must have the BP7 > compatibility which is very good in 1.0.10. What about Mark and Release when talking about heap management ;)? A compromise would be a tpascal unit which is loaded only in -So mode. _______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel