1
0
Fork 0

Valgrind garbage collection shutdown fix attempt

This commit is contained in:
jsteemann 2016-01-12 14:27:23 +01:00
parent 780f791891
commit 14216e4ca5
3 changed files with 20 additions and 7 deletions

View File

@ -1449,10 +1449,20 @@ void ApplicationV8::shutdownV8Instance(size_t i) {
double availableTime = 30.0;
if (RUNNING_ON_VALGRIND) {
// running under Valgrind
availableTime *= 10;
}
int tries = 0;
TRI_RunGarbageCollectionV8(isolate, availableTime);
while (tries++ < 10 &&
TRI_RunGarbageCollectionV8(isolate, availableTime)) {
if (tries > 3) {
LOG_WARNING("waiting for garbage v8 collection to end");
}
}
}
else {
TRI_RunGarbageCollectionV8(isolate, availableTime);
}
TRI_GET_GLOBALS();
if (v8g != nullptr) {

View File

@ -4068,10 +4068,11 @@ static bool SingleRunGarbageCollectionV8(v8::Isolate* isolate,
////////////////////////////////////////////////////////////////////////////////
/// @brief run the V8 garbage collection for at most a specifiable amount of
/// time
/// time. returns a boolean indicating whether or not the caller should attempt
/// to do more gc
////////////////////////////////////////////////////////////////////////////////
void TRI_RunGarbageCollectionV8(v8::Isolate* isolate, double availableTime) {
bool TRI_RunGarbageCollectionV8(v8::Isolate* isolate, double availableTime) {
int idleTimeInMs = 1000;
if (availableTime >= 5.0) {
@ -4097,7 +4098,7 @@ void TRI_RunGarbageCollectionV8(v8::Isolate* isolate, double availableTime) {
while (++gcTries <= gcAttempts) {
if (SingleRunGarbageCollectionV8(isolate, idleTimeInMs)) {
return;
return false;
}
}
@ -4108,12 +4109,14 @@ void TRI_RunGarbageCollectionV8(v8::Isolate* isolate, double availableTime) {
// much CPU
if (++gcTries > gcAttempts ||
SingleRunGarbageCollectionV8(isolate, idleTimeInMs)) {
return;
return false;
}
}
usleep(100);
}
return true;
}
////////////////////////////////////////////////////////////////////////////////

View File

@ -182,7 +182,7 @@ void TRI_normalize_V8_Obj(const v8::FunctionCallbackInfo<v8::Value>& args,
/// time
////////////////////////////////////////////////////////////////////////////////
void TRI_RunGarbageCollectionV8(v8::Isolate*, double);
bool TRI_RunGarbageCollectionV8(v8::Isolate*, double);
////////////////////////////////////////////////////////////////////////////////
/// @brief clear the instance-local cache of wrapped objects