Welcome, Guest. Please login or register.

Author Topic: Saving to HD with almost zero free memory possible ?  (Read 2134 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline platon42

  • Hero Member
  • *****
  • Join Date: Jul 2002
  • Posts: 573
    • Show all replies
    • http://www.platon42.de/
Re: Saving to HD with almost zero free memory possible ?
« on: February 02, 2006, 07:24:37 PM »
... or, of course, you could allocate some memory before and write a low memory handler that would free the memory on a low memory situation and right after that would write a log report to disk (and hopefully, the memory you freed would ensure a stable system to write the file back to disk (I believe this operation won't use much memory, if any at all)).

But beware, low memory handlers are also triggered by "avail flush" aka flushlibs.
--
Regards, Chris Hodges )-> http://www.platon42.de <-(
hackerkey://v4sw7CJS$hw6/7ln6pr7+8AOP$ck0ma8u2LMw1/4Xm5l3i5TJCOTextPad/e7t2BDMNb7GHLen5a34s5IMr1g3/5ACM
 

Offline platon42

  • Hero Member
  • *****
  • Join Date: Jul 2002
  • Posts: 573
    • Show all replies
    • http://www.platon42.de/
Re: Saving to HD with almost zero free memory possible ?
« Reply #1 on: February 02, 2006, 11:07:24 PM »
> That's great (reserving a big enouph chunk for my program when it launches) but the problem is that it allocates memory dynamically.

That's not what I meant. The memory I'm talking about that is allocated at start is meant to be a "last resort" memory for *other* programs (as it is supposed to be freed by the low memory handler (see exec/AddMemHandler() for details), and signals your main task to panic, and save the errorlog to disk).

About dynamic memory, I strongly suggest you're using memory pools (as others already mentioned it).
--
Regards, Chris Hodges )-> http://www.platon42.de <-(
hackerkey://v4sw7CJS$hw6/7ln6pr7+8AOP$ck0ma8u2LMw1/4Xm5l3i5TJCOTextPad/e7t2BDMNb7GHLen5a34s5IMr1g3/5ACM