void *MSmall::Alloc(size_t sz) { if(sz <= 256) { ATIMING("Small alloc"); int k = ((int)sz + (sz == 0) - 1) >> 4; sHeapStat(k); return CheckFree(AllocK(k), k); }
static void WriteExportInfo( void *_exp, void *info ) /***************************************************/ { entry_export *exp = _exp; if( !CheckFree( exp->isfree, info ) ) { exp->next = CarveGetIndex( CarveExportInfo, exp->next ); if( exp->name != NULL ) { exp->name = GetString( info, exp->name ); } BufWritePermFile( info, exp, offsetof(entry_export, sym) ); } }
static void WriteDLLInfo( void *_dll, void *info ) /************************************************/ { dll_sym_info *dll = _dll; if( !CheckFree( dll->isfree, info ) ) { dll->m.modname = dll->m.modnum->name; if( !dll->isordinal ) { dll->u.entname = dll->u.entry->name; } BufWritePermFile( info, dll, offsetof(dll_sym_info, iatsym) ); } }
cl_mem dpoCContext::CreateBuffer(cl_mem_flags flags, size_t size, void *ptr, cl_int *err) { #ifdef INCREMENTAL_MEM_RELEASE int freed; cl_mem result; do { freed = CheckFree(); result = clCreateBuffer(context, flags, size, ptr, err); } while (((*err == CL_OUT_OF_HOST_MEMORY) || (*err == CL_MEM_OBJECT_ALLOCATION_FAILURE)) && freed); return result; #else /* INCREMENTAL_MEM_RELEASE */ return clCreateBuffer(context, flags, size, ptr, err); #endif /* INCREMENTAL_MEM_RELEASE */ }
dpoCContext::~dpoCContext() { DEBUG_LOG_DESTROY("dpoCContext", this); #ifdef INCREMENTAL_MEM_RELEASE // disable deferred free defer_max = 0; // free the pending queue while (CheckFree()) {}; nsMemory::Free(defer_list); defer_list = NULL; #endif /* INCREMENTAL_MEM_RELEASE */ if (buildLog != NULL) { nsMemory::Free(buildLog); } if (cmdQueue != NULL) { clReleaseCommandQueue(cmdQueue); } }
cl_mem dpoCContext::CreateBuffer(JSContext *cx, cl_mem_flags flags, size_t size, void *ptr, cl_int *err) { #ifdef INCREMENTAL_MEM_RELEASE int freed; cl_mem result; bool didGC = false; do { freed = CheckFree(); result = clCreateBuffer(context, flags, size, ptr, err); if ((*err != CL_OUT_OF_HOST_MEMORY) && (*err != CL_MEM_OBJECT_ALLOCATION_FAILURE) && (*err != CL_OUT_OF_RESOURCES)) break; if (!freed && !didGC) { JS_GC(JS_GetRuntime(cx)); didGC = freed = true; } } while (freed); return result; #else /* INCREMENTAL_MEM_RELEASE */ return clCreateBuffer(context, flags, size, ptr, err); #endif /* INCREMENTAL_MEM_RELEASE */ }
//Runnable void RedisClientManager::run(tbsys::CThread* thread, void* arg) { int timer_check_reconn=0;//1s int timer_check_free=20;//30s while (!stop_) { if (0==timer_check_reconn) { CheckReconn(); } if (0==timer_check_free) { CheckFree(); } if (1==++timer_check_reconn) { timer_check_reconn=0; } if (30==++timer_check_free) { timer_check_free=0; } usleep(1000000); } }