Trigger full GC from CodeManager to fix memory use #2225

Merged
merged 3 commits into from Mar 25, 2013
Jump to file or symbol
Failed to load files and symbols.
+21 −7
Split
@@ -48,11 +48,11 @@ namespace rubinius {
CompiledCode* CompiledCode::create(STATE) {
CompiledCode* code = state->new_object<CompiledCode>(G(compiled_code));
code->local_count(state, Fixnum::from(0));
- code->set_executor(CompiledCode::default_executor);
- code->machine_code_ = NULL;
code->inliners_ = 0;
code->prim_index_ = -1;
+ code->set_executor(CompiledCode::default_executor);
+ code->machine_code_ = NULL;
#ifdef ENABLE_LLVM
code->jit_data_ = NULL;
#endif
@@ -65,8 +65,10 @@ namespace rubinius {
code->copy_object(state, this);
code->set_executor(CompiledCode::default_executor);
- code->jit_data_ = NULL;
code->machine_code_ = NULL;
+#ifdef ENABLE_LLVM
+ code->jit_data_ = NULL;
+#endif
return code;
}
@@ -251,7 +253,9 @@ namespace rubinius {
machine_code_->set_execute_status(MachineCode::eJIT);
+#ifdef ENABLE_LLVM
jit_data_ = rd;
+#endif
machine_code_->unspecialized = exec;
// See if we can also just make this the normal execute
@@ -33,12 +33,14 @@ namespace rubinius {
Tuple* lines_; // slot
Tuple* local_names_; // slot
Symbol* file_; // slot
- ConstantScope* scope_; // slot
+ ConstantScope* scope_; // slot
LookupTable* breakpoints_; // slot
MachineCode* machine_code_;
+#ifdef ENABLE_LLVM
jit::RuntimeDataHolder* jit_data_;
+#endif
public:
// Access directly from assembly, so has to be public.
View
@@ -26,6 +26,7 @@ namespace rubinius {
, freed_resources_(0)
, total_allocated_(0)
, total_freed_(0)
+ , gc_triggered_(0)
, bytes_used_(0)
{
first_chunk_ = new Chunk(chunk_size_);
@@ -58,12 +59,17 @@ namespace rubinius {
current_chunk_ = c;
}
- void CodeManager::add_resource(CodeResource* cr) {
+ void CodeManager::add_resource(CodeResource* cr, bool* collect_now) {
utilities::thread::Mutex::LockGuard guard(mutex_);
total_allocated_ += cr->size();
bytes_used_ += cr->size();
+ if(total_allocated_ - gc_triggered_ > cGCTriggerThreshold) {
+ gc_triggered_ = total_allocated_;
+ *collect_now = true;
+ }
+
for(;;) {
while(current_index_ < chunk_size_) {
if(current_chunk_->resources[current_index_] == 0) {
View
@@ -25,6 +25,7 @@ namespace rubinius {
class CodeManager {
const static int cDefaultChunkSize = 64;
+ const static int cGCTriggerThreshold = 64 * 1024 * 1024;
/**
* A chunk of memory used to store an array of references to CodeResource
@@ -55,6 +56,7 @@ namespace rubinius {
int freed_resources_;
int total_allocated_;
int total_freed_;
+ int gc_triggered_;
size_t bytes_used_;
@@ -83,7 +85,7 @@ namespace rubinius {
CodeManager(SharedState* shared, int chunk_size=cDefaultChunkSize);
~CodeManager();
- void add_resource(CodeResource* cr);
+ void add_resource(CodeResource* cr, bool* collect_now);
void clear_marks();
void sweep();
int calculate_size();
View
@@ -902,7 +902,7 @@ namespace rubinius {
void ObjectMemory::add_code_resource(CodeResource* cr) {
SYNC_TL;
- code_manager_.add_resource(cr);
+ code_manager_.add_resource(cr, &collect_mature_now);
}
void* ObjectMemory::young_start() {