Skip to content

Remove default allocator for estell exceptions #65

@kammce

Description

@kammce

Currently we allocate 256 bytes for a single exception to be thrown in a single core system. This is useful for developers but has a cost of losing a bit more than 256 bytes of memory.

New behavior

  • Keep a statically allocated polymorphic allocator (should be the cost of a pointer)
  • The application is forced to set an exception allocator prior to using anything that can throw an exception
  • If an exception is thrown without an allocator set, then the application terminates.
  • The set_exception_allocator() will allocate and deallocate an instance of std::bad_alloc to verify that the allocator can at least allocate std::bad_alloc object. The assumption will be that the allocator can at least allocate std::bad_alloc.
  • If the exception allocator has completely exhausted and is unable to allocate a bad alloc object, then the application terminates.

Another option other than terminating the application would be to have some reserve memory for std::bad_alloc, but this has a per-thread cost that I think is unreasonable for many applications. So termination seems like the proper action if error reporting fails.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions