Beispiel #1
0
/*
 *  Collect the garbage. This is a mark and sweep over all possible objects. If an object is not referenced, it and 
 *  all contained properties will be freed. Collection is done in generations.
 */
void ejsCollectGarbage(Ejs *ejs, int gen)
{
    EjsGC       *gc;
    
    gc = &ejs->gc;
    if (!gc->enabled || gc->collecting || !ejs->initialized) {
        return;
    }
    gc->collecting = 1;

    mark(ejs, gen);
    sweep(ejs, gen);
    if (!memoryUsageOk(ejs)) {
        pruneTypePools(ejs);
    }
    ejs->workDone = 0;
    ejs->gcRequired = 0;
    gc->collecting = 0;
#if BLD_DEBUG
    gc->totalSweeps++;
#if REPORT
    ejsPrintAllocReport(ejs);
    mprPrintAllocReport(ejs, "Memory Report");
#endif
#endif
}
Beispiel #2
0
void mprTerm(MprApp *app, bool doStats)
{
#if BLD_FEATURE_ALLOC_STATS
	if (doStats) {
		mprPrintAllocReport(app, 1, "MPR Memory Allocation Report");
	}
#endif

#if BLD_FEATURE_MULTITHREAD
	mprTermThreads(app);
#endif

	mprStopFileServices(app);

#if BLD_DEBUG
	mprValidateAllocTree(app);
#endif
	mprAllocTerm(app);
}
Beispiel #3
0
/*
 *  native static function stats(): Void
 */
static EjsVar *printStats(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv)
{
    ejsPrintAllocReport(ejs);
    mprPrintAllocReport(ejs, "Memory Report");
    return 0;
}