Exemple #1
0
void output_statistics(void*)
{
	llinfos << "Number of orphans: " << gObjectList.getOrphanCount() << llendl;
	llinfos << "Number of dead objects: " << gObjectList.mNumDeadObjects << llendl;
	llinfos << "Num images: " << gImageList.getNumImages() << llendl;
	llinfos << "Texture usage: " << LLImageGL::sGlobalTextureMemoryInBytes << llendl;
	llinfos << "Texture working set: " << LLImageGL::sBoundTextureMemoryInBytes << llendl;
	llinfos << "Raw usage: " << LLImageRaw::sGlobalRawMemory << llendl;
	llinfos << "Formatted usage: " << LLImageFormatted::sGlobalFormattedMemory << llendl;
	llinfos << "Zombie Viewer Objects: " << LLViewerObject::getNumZombieObjects() << llendl;
	llinfos << "Number of lights: " << gPipeline.getLightCount() << llendl;

	llinfos << "Memory Usage:" << llendl;
	llinfos << "--------------------------------" << llendl;
	llinfos << "Pipeline:" << llendl;
	llinfos << llendl;

#if LL_SMARTHEAP
	llinfos << "--------------------------------" << llendl;
	{
		llinfos << "sizeof(LLVOVolume) = " << sizeof(LLVOVolume) << llendl;

		U32 total_pool_size = 0;
		U32 total_used_size = 0;
		MEM_POOL_INFO pool_info;
		MEM_POOL_STATUS pool_status;
		U32 pool_num = 0;
		for(pool_status = MemPoolFirst( &pool_info, 1 ); 
			pool_status != MEM_POOL_END; 
			pool_status = MemPoolNext( &pool_info, 1 ) )
		{
			llinfos << "Pool #" << pool_num << llendl;
			if( MEM_POOL_OK != pool_status )
			{
				llwarns << "Pool not ok" << llendl;
				continue;
			}

			llinfos << "Pool blockSizeFS " << pool_info.blockSizeFS
				<< " pageSize " << pool_info.pageSize
				<< llendl;

			U32 pool_count = MemPoolCount(pool_info.pool);
			llinfos << "Blocks " << pool_count << llendl;

			U32 pool_size = MemPoolSize( pool_info.pool );
			if( pool_size == MEM_ERROR_RET )
			{
				llinfos << "MemPoolSize() failed (" << pool_num << ")" << llendl;
			}
			else
			{
				llinfos << "MemPool Size " << pool_size / 1024 << "K" << llendl;
			}

			total_pool_size += pool_size;

			if( !MemPoolLock( pool_info.pool ) )
			{
				llinfos << "MemPoolLock failed (" << pool_num << ") " << llendl;
				continue;
			}

			U32 used_size = 0; 
			MEM_POOL_ENTRY entry;
			entry.entry = NULL;
			while( MemPoolWalk( pool_info.pool, &entry ) == MEM_POOL_OK )
			{
				if( entry.isInUse )
				{
					used_size += entry.size;
				}
			}

			MemPoolUnlock( pool_info.pool );

			llinfos << "MemPool Used " << used_size/1024 << "K" << llendl;
			total_used_size += used_size;
			pool_num++;
		}
		
		llinfos << "Total Pool Size " << total_pool_size/1024 << "K" << llendl;
		llinfos << "Total Used Size " << total_used_size/1024 << "K" << llendl;

	}
#endif

	llinfos << "--------------------------------" << llendl;
	llinfos << "Avatar Memory (partly overlaps with above stats):" << llendl;
	gTexStaticImageList.dumpByteCount();
	LLVOAvatar::dumpScratchTextureByteCount();
	LLTexLayerSetBuffer::dumpTotalByteCount();
	LLVOAvatar::dumpTotalLocalTextureByteCount();
	LLTexLayerParamAlpha::dumpCacheByteCount();
	LLVOAvatar::dumpBakedStatus();

	llinfos << llendl;

	llinfos << "Object counts:" << llendl;
	S32 i;
	S32 obj_counts[256];
//	S32 app_angles[256];
	for (i = 0; i < 256; i++)
	{
		obj_counts[i] = 0;
	}
	for (i = 0; i < gObjectList.getNumObjects(); i++)
	{
		LLViewerObject *objectp = gObjectList.getObject(i);
		if (objectp)
		{
			obj_counts[objectp->getPCode()]++;
		}
	}
	for (i = 0; i < 256; i++)
	{
		if (obj_counts[i])
		{
			llinfos << LLPrimitive::pCodeToString(i) << ":" << obj_counts[i] << llendl;
		}
	}
}
void UI_Cleanup()
{
	int i;

	SetCursor(gCursors[CRSR_WAIT]);
	if(UI_VuThread)
	{
		delete UI_VuThread;
		UI_VuThread=NULL;
	}

	if(gCommsMgr)
		for(i=0;i<game_MaxGameTypes;i++)
			gCommsMgr->SetCallback(i,NULL); // Disable callbacks we don't care about when NOT in the UI

// End Event Loop
	Sleep(10);

	if(gMapMgr)
	{
		gMapMgr->Cleanup();
		delete gMapMgr;
		gMapMgr=NULL;
	}

	if(gMainHandler)
	{
		gMainHandler->Cleanup();
		delete gMainHandler;
		gMainHandler=NULL;
	}

	if(gUIViewer)
	{
		delete gUIViewer;
		gUIViewer = NULL;
	}

	OTWDriver.CleanViewpoint(); // JB 010615
	DeviceDependentGraphicsCleanup( &FalconDisplay.theDisplayDevice );

	if(gMusic)
	{
		gMusic->Cleanup();
		delete gMusic;
		gMusic=NULL;
	}

	if(gSoundMgr)
	{
		gSoundMgr->Cleanup();
		delete gSoundMgr;
		gSoundMgr=NULL;
	}

	if(gPopupMgr)
	{
		gPopupMgr->Cleanup();
		delete gPopupMgr;
		gPopupMgr=NULL;
	}

	if(gImageMgr)
	{
		gImageMgr->Cleanup();
		delete gImageMgr;
		gImageMgr=NULL;
	}

	if(gAnimMgr)
	{
		gAnimMgr->Cleanup();
		delete gAnimMgr;
		gAnimMgr=NULL;
	}

	if(gOccupationMap)
	{
		C_Resmgr *mgr;
		mgr=gOccupationMap->Owner;
		mgr->Cleanup();
		delete mgr;
		gOccupationMap=NULL;
	}

	if(gMainParser)
	{
		gMainParser->Cleanup();
		delete gMainParser;
		gMainParser=NULL;
	}

	if(gFontList)
	{
		gFontList->Cleanup();
		delete gFontList;
		gFontList=NULL;
	}

	if(gStringMgr)
	{
		gStringMgr->Cleanup();
		delete gStringMgr;
		gStringMgr=NULL;
	}

	if(gMovieMgr)
	{
		gMovieMgr->Cleanup();
		delete gMovieMgr;
		gMovieMgr=NULL;
	}

	IALoaded=0;
	ACMILoaded=0;
	DFLoaded=0;
	TACLoaded=0;
	CPLoaded=0;
	CPSelectLoaded=0;
	LBLoaded=0;
	STPLoaded=0;
	COLoaded=0;
	MainLoaded=0;
	PlannerLoaded=0;
	TACREFLoaded=0;
	CommonLoaded=0;
	INFOLoaded = 0;
	HelpLoaded = 0;
	TACSelLoaded = 0;

	if(gPlayerBook)
	{
		gPlayerBook->Save("phonebkn.da2");
		gPlayerBook->Cleanup();
		delete gPlayerBook;
		gPlayerBook=NULL;
	}

#ifdef __WATCOMC__
#pragma warning 379 4;
#endif

	if(People)
	{ // Now maintained in a script
		People=NULL;
	}
	if(DogfightGames)
	{ // Now maintained in a script
		DogfightGames=NULL;
	}
	if(TacticalGames)
	{ // Now maintained in a script
		TacticalGames=NULL;
	}
	if(CampaignGames)
	{ // Now maintained in a script
		CampaignGames=NULL;
	}

	if(gUICommsQ)
	{
		F4EnterCriticalSection(vuCritical);
		gUICommsQ->Cleanup();
		delete gUICommsQ;
		gUICommsQ=NULL;
		F4LeaveCriticalSection(vuCritical);
	}

	if(gInstantBites)
	{
		gInstantBites->Cleanup();
		delete gInstantBites;
		gInstantBites=NULL;
	}

	if(gDogfightBites)
	{
		gDogfightBites->Cleanup();
		delete gDogfightBites;
		gDogfightBites=NULL;
	}

	if(gCampaignBites)
	{
		gCampaignBites->Cleanup();
		delete gCampaignBites;
		gCampaignBites=NULL;
	}

	ShutdownSetup();

	PlayerOptions.SaveOptions();
	LogBook.SaveData();

	if(KeyDescrips)
		CleanupKeys();

	//UserFunctionTable.ClearTable();

	for(i=1;i<MAX_CURSORS;i++)
		if(gCursors[i])
			DeleteObject(gCursors[i]);

	if(gScreenShotEnabled && gScreenShotBuffer)
	{
		delete gScreenShotBuffer;
		gScreenShotBuffer=NULL;
	}

#ifdef USE_SH_POOLS
#if 0
	// Shrink Memory Pools to find out how much is still active
	MemPoolShrink(UI_Pools[UI_GENERAL_POOL]);
	MemPoolShrink(UI_Pools[UI_CONTROL_POOL]);
	MemPoolShrink(UI_Pools[UI_ART_POOL]);
	MemPoolShrink(UI_Pools[UI_SOUND_POOL]);

	// Display amout of leakage in these Pools
	MonoPrint("Memory Blocks allocated AFTER cleanup\n");
	MonoPrint("UI_Pools[UI_GENERAL_POOL] size = %1lu\n",MemPoolCount(UI_Pools[UI_GENERAL_POOL]));
	MonoPrint("UI_Pools[UI_CONTROL_POOL] size = %1lu\n",MemPoolCount(UI_Pools[UI_CONTROL_POOL]));
	MonoPrint("UI_Pools[UI_ART_POOL] size = %1lu\n",MemPoolCount(UI_Pools[UI_ART_POOL]));
	MonoPrint("UI_Pools[UI_SOUND_POOL] size = %1lu\n",MemPoolCount(UI_Pools[UI_SOUND_POOL]));

	dbgMemSetCheckpoint(11);

	if (lastErrorFn)
	{
		MemSetErrorHandler(lastErrorFn);
		dbgMemSetDefaultErrorOutput(DBGMEM_OUTPUT_FILE,"uileak1.log");
		dbgMemReportLeakage(UI_Pools[UI_GENERAL_POOL],10,11);
		dbgMemSetDefaultErrorOutput(DBGMEM_OUTPUT_FILE,"uileak2.log");
		dbgMemReportLeakage(UI_Pools[UI_CONTROL_POOL],10,11);
		dbgMemSetDefaultErrorOutput(DBGMEM_OUTPUT_FILE,"uileak3.log");
		dbgMemReportLeakage(UI_Pools[UI_ART_POOL],10,11);
		dbgMemSetDefaultErrorOutput(DBGMEM_OUTPUT_FILE,"uileak4.log");
		dbgMemReportLeakage(UI_Pools[UI_SOUND_POOL],10,11);
		MemSetErrorHandler(errPrint);
	}
#endif
	// Free up Memory Pools
	MemPoolFree(UI_Pools[UI_GENERAL_POOL]);
	MemPoolFree(UI_Pools[UI_CONTROL_POOL]);
	MemPoolFree(UI_Pools[UI_ART_POOL]);
	MemPoolFree(UI_Pools[UI_SOUND_POOL]);
#endif

	FalconDisplay.LeaveMode();

	// OW
	//ShowCursor(FALSE);
	while(ShowCursor(FALSE) >= 0);

	// OW
//    SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL);
}