c++ - Side effects of exit() without exiting? -


if application runs out of memory, re-run changed parameters. have malloc / new in various parts of application, sizes of not known in advance. see 2 options:

  • track memory allocations , write restarting procedure deallocates before re-running changed parameters. (of course, free memory @ appropriate places if no errors occur)
  • restarting application (e.g., winexec() on windows) , exiting

i not thrilled either solution. did miss alternative maybe.

thanks

simplicity rules: restart app different parameters.

it hard either track down allocs/deallocs , clean memory (just forget minor blocks inside bigger chunks [fragmentation] , still have problems rerun class), or introduce own heap-management (very clever people have invested years bring nedmalloc etc live, not fool illusion easy task).

so:

  • catch "out of memory" somehow (signals, or std::bad_alloc, or whatever)
  • create new process of app:
    • windows: createprocess() (you can exit() program after this, cleans allocated resources you)
    • unix: exec() (replaces current process completely, "cleans memory" you)
  • done.

Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -