vm: don't keep more than 10 unused contexts around to prevent address space wastage on low-budget operating systems like OpenBSD
parent
e8b1a06dad
commit
a36bd7fbaf
|
@ -111,8 +111,8 @@ void factor_vm::init_contexts(cell datastack_size_, cell retainstack_size_, cell
|
|||
void factor_vm::delete_contexts()
|
||||
{
|
||||
assert(!ctx);
|
||||
std::vector<context *>::const_iterator iter = unused_contexts.begin();
|
||||
std::vector<context *>::const_iterator end = unused_contexts.end();
|
||||
std::list<context *>::const_iterator iter = unused_contexts.begin();
|
||||
std::list<context *>::const_iterator end = unused_contexts.end();
|
||||
while(iter != end)
|
||||
{
|
||||
delete *iter;
|
||||
|
@ -159,6 +159,13 @@ void factor_vm::delete_context(context *old_context)
|
|||
{
|
||||
unused_contexts.push_back(old_context);
|
||||
active_contexts.erase(old_context);
|
||||
|
||||
while(unused_contexts.size() > 10)
|
||||
{
|
||||
context *stale_context = unused_contexts.front();
|
||||
unused_contexts.pop_front();
|
||||
delete stale_context;
|
||||
}
|
||||
}
|
||||
|
||||
VM_C_API void delete_context(factor_vm *parent, context *old_context)
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
/* C++ headers */
|
||||
#include <algorithm>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
|
Loading…
Reference in New Issue