Skip to content

Commit

Permalink
reverting changes to size_limiter example
Browse files Browse the repository at this point in the history
  • Loading branch information
kab163 committed Jan 23, 2025
1 parent 2d70aec commit fc8704c
Showing 1 changed file with 1 addition and 17 deletions.
18 changes: 1 addition & 17 deletions examples/size_limiter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <iostream>

#include "umpire/ResourceManager.hpp"
#include "umpire/Umpire.hpp"
#include "umpire/strategy/QuickPool.hpp"
#include "umpire/strategy/SizeLimiter.hpp"
#include "umpire/util/Macros.hpp"
Expand All @@ -19,30 +18,15 @@ int main(int, char**)
rm.makeAllocator<umpire::strategy::SizeLimiter>("size_limited_alloc", rm.getAllocator("HOST"), 1024);

auto pool = rm.makeAllocator<umpire::strategy::QuickPool>("pool", size_limited_alloc, 64, 64);
void* data;

// This will throw an exception because the pool is limited to 1024 bytes.
std::cout << "Attempting to allocate 2098 bytes..." << std::endl;
try {
data = pool.allocate(2048);
void* data = pool.allocate(2048);
UMPIRE_USE_VAR(data);
} catch (...) {
std::cout << "Exception caught! Pool is limited to 1024 bytes." << std::endl;
}
std::cout << "The total amount of memory used was: " << umpire::get_total_memory_allocated() << std::endl;

std::cout << "Attempting to allocate 512 bytes..." << std::endl;
try {
data = pool.allocate(512);
UMPIRE_USE_VAR(data);
} catch (...) {
std::cout << "Exception caught! Pool is limited to 1024 bytes." << std::endl;
}
std::cout << "The total amount of memory used was: " << umpire::get_total_memory_allocated() << std::endl;

if (data != nullptr) {
pool.deallocate(data);
}

return 0;
}

0 comments on commit fc8704c

Please # to comment.