// once reload is implemented for the memory manager, the configuration
// model will need to be updated
-void MemoryCap::calculate(unsigned num_threads)
+void MemoryCap::calculate()
{
assert(!is_packet_thread());
const MemoryConfig& config = *SnortConfig::get_conf()->memory;
- auto main_thread_used = s_tracker.used();
-
- if ( !config.cap )
- {
- thread_cap = preemptive_threshold = 0;
- return;
- }
-
- if ( main_thread_used > config.cap )
- {
- ParseError("main thread memory usage (%zu) is greater than cap\n", main_thread_used);
- return;
- }
-
- auto real_cap = config.cap - main_thread_used;
- thread_cap = real_cap / num_threads;
-
- // FIXIT-L do we want to add some fixed overhead to allow the packet threads to
- // startup and preallocate flows and whatnot?
-
- if ( !thread_cap )
- {
- ParseError("per-thread memory cap is 0");
- return;
- }
-
- if ( config.threshold )
- preemptive_threshold = memory::calculate_threshold(thread_cap, config.threshold);
+ thread_cap = config.cap;
+ preemptive_threshold = memory::calculate_threshold(thread_cap, config.threshold);
}
void MemoryCap::print()
if ( !MemoryModule::is_active() )
return;
- const MemoryConfig& config = *SnortConfig::get_conf()->memory;
-
if ( SnortConfig::log_verbose() or mem_stats.allocations )
LogLabel("memory (heap)");
if ( SnortConfig::log_verbose() )
{
- LogMessage(" global cap: %zu\n", config.cap);
- LogMessage(" global preemptive threshold percent: %u\n", config.threshold);
+ LogMessage(" thread cap: %zu\n", thread_cap);
+ LogMessage(" thread preemptive threshold: %zu\n", preemptive_threshold);
}
if ( mem_stats.allocations )
LogMessage(" main thread usage: %zu\n", s_tracker.used());
LogMessage(" allocations: %" PRIu64 "\n", mem_stats.allocations);
LogMessage(" deallocations: %" PRIu64 "\n", mem_stats.deallocations);
- LogMessage(" thread cap: %zu\n", thread_cap);
- LogMessage(" preemptive threshold: %zu\n", preemptive_threshold);
}
}