diff options
Diffstat (limited to 'examples/graph_vgg19.cpp')
-rw-r--r-- | examples/graph_vgg19.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/examples/graph_vgg19.cpp b/examples/graph_vgg19.cpp index ff7cf751a1..3b1773519a 100644 --- a/examples/graph_vgg19.cpp +++ b/examples/graph_vgg19.cpp @@ -40,6 +40,16 @@ public: } bool do_setup(int argc, char **argv) override { + // Check if the system has enough RAM to run the example, systems with less than 2GB have + // to hint the API to minimize memory consumption otherwise it'll run out of memory and + // fail throwing the bad_alloc exception + arm_compute::MEMInfo meminfo; + const size_t mem_total = meminfo.get_total_in_kb(); + if(mem_total <= arm_compute::MEMInfo::TWO_GB_IN_KB) + { + arm_compute::MEMInfo::set_policy(arm_compute::MemoryPolicy::MINIMIZE); + } + // Parse arguments cmd_parser.parse(argc, argv); |