Skip to content

Commit

Permalink
Merge pull request #27 from cactusdynamics/no-heap-allocation-by-default
Browse files Browse the repository at this point in the history
Do not reserve memory by default
  • Loading branch information
shuhaowu authored Jan 30, 2023
2 parents 614ad74 + ca23d83 commit d67c698
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/cactus_rt/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class App {
* @brief Creates an instance of the RT app. The app should always be created
* before the threads as some global setup that can take place.
*
* @param heap_size The heap size to reserve in bytes. Defaults to 512MB.
* @param heap_size The heap size to reserve in bytes. Defaults to 0 which means no heap memory will be reserved.
*/
explicit App(size_t heap_size = 512 * 1024 * 1024) : heap_size_(heap_size) {}
explicit App(size_t heap_size = 0) : heap_size_(heap_size) {}
virtual ~App() = default;

// Copy constructors
Expand Down
2 changes: 2 additions & 0 deletions src/app.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ void App::ReserveHeap() const {
return;
}

SPDLOG_INFO("reserving {} bytes of heap memory", heap_size_);

void* buf = malloc(heap_size_);
if (buf == nullptr) {
SPDLOG_ERROR("cannot malloc: {}", std::strerror(errno));
Expand Down

0 comments on commit d67c698

Please sign in to comment.