예제 #1
0
void memLimitCheck()
{
    if (file_count % 1000 == 0)
    {
        debug_msg("MEM USAGE: %li MB\n", (unsigned long)getCurrentRSS()/(1024UL*1024UL));
    }
    if ((file_count % 1000 == 0) && MEMORY_LIMIT< (int)getCurrentRSS()/(1024UL*1024UL))
    {
        safeexit();
        fprintf(stderr, "Memory out of limit! Exiting..\n");
        exit(EXIT_FAILURE);
    }
    return;
}
예제 #2
0
void resourceMonitorLoop(void* t) {
	auto timer = (basicResourceMonitor*)t;
	long long time = 0;
	int sleep = 10;
	while (not timer->requestedToStop()) {
		time += sleep;
#ifdef __MINGW32__
		Sleep(sleep);
#else
		usleep(sleep * 1000);
#endif

		if (sleep < 1000) {
			if (sleep < 100) {
				sleep += 10;
			} else {
				sleep += 100;
			}
		}
		if (timer->call_for_timebound() < time / 1000) {
			timer->_wentOut = true;
			timer->call_on_timeout();
			break;
		}
		if(timer->call_for_memorybound() < (long)getCurrentRSS()/1024/1024){
			timer->_wentOut = true;
			timer->call_on_timeout();
			break;
		}
	}
}
예제 #3
0
// Write some stats to llinfos
void display_stats()
{
	if (gNoRender || !gViewerWindow->mWindow->getVisible() || !gFocusMgr.getAppHasFocus())
	{
		// Do not keep FPS statistics while yielding cooperatively
		// (i;e. when not running as foreground window)
		gRecentFrameCount = 0;
		gRecentFPSTime.reset();
	}
	F32 fps_log_freq = gSavedSettings.getF32("FPSLogFrequency");
	if (fps_log_freq > 0.f && gRecentFPSTime.getElapsedTimeF32() >= fps_log_freq)
	{
		F32 fps = gRecentFrameCount / fps_log_freq;
		llinfos << llformat("FPS: %.02f", fps) << llendl;
		gRecentFrameCount = 0;
		gRecentFPSTime.reset();
	}
	F32 mem_log_freq = gSavedSettings.getF32("MemoryLogFrequency");
	if (mem_log_freq > 0.f && gRecentMemoryTime.getElapsedTimeF32() >= mem_log_freq)
	{
		gMemoryAllocated = getCurrentRSS();
		U32 memory = (U32)(gMemoryAllocated / (1024*1024));
		llinfos << llformat("MEMORY: %d MB", memory) << llendl;
		gRecentMemoryTime.reset();
	}
}
예제 #4
0
파일: rss.c 프로젝트: firebitsbr/book-srcs
void main(void)
{
#if defined(__linux)
  struct sysinfo si;

  sysinfo(&si);   
  printf("System wide available memory: %s\n", human_readable(si.freeram));
#endif

  printf("RSS: %s\n"
         "Peak RSS: %s\n",
         human_readable(getCurrentRSS()), human_readable(getPeakRSS()));
}
예제 #5
0
파일: util.cpp 프로젝트: msjoberg/pumpa
void checkMemory(QString desc) {
  static long oldMem = -1;
  
  long mem = getCurrentRSS();
  long diff = 0;
  if (oldMem > 0)
    diff = mem-oldMem;

  QString msg("RESIDENT MEMORY");
  if (!desc.isEmpty())
    msg += " (" + desc + ")";
  msg += QString(": %1 KB").arg((float)mem/1024.0, 0, 'f', 2);
  if (diff != 0)
    msg += QString(" (%2%1)").arg(diff).arg(diff > 0 ? '+' : '-');

  qDebug() << msg;
}
예제 #6
0
// Write some stats to llinfos
void display_stats()
{
	F32 fps_log_freq = gSavedSettings.getF32("FPSLogFrequency");
	if (fps_log_freq > 0.f && gRecentFPSTime.getElapsedTimeF32() >= fps_log_freq)
	{
		F32 fps = gRecentFrameCount / fps_log_freq;
		llinfos << llformat("FPS: %.02f", fps) << llendl;
		gRecentFrameCount = 0;
		gRecentFPSTime.reset();
	}
	F32 mem_log_freq = gSavedSettings.getF32("MemoryLogFrequency");
	if (mem_log_freq > 0.f && gRecentMemoryTime.getElapsedTimeF32() >= mem_log_freq)
	{
		gMemoryAllocated = getCurrentRSS();
		U32 memory = (U32)(gMemoryAllocated / (1024*1024));
		llinfos << llformat("MEMORY: %d MB", memory) << llendl;
		gRecentMemoryTime.reset();
	}
}
예제 #7
0
/*
 * The sim-side LLSD is in newsim/llagentinfo.cpp:forwardViewerStats.
 *
 * There's also a compatibility shim for the old fixed-format sim
 * stats in newsim/llagentinfo.cpp:processViewerStats.
 *
 * If you move stats around here, make the corresponding changes in
 * those locations, too.
 */
void send_stats()
{
	// <edit> Don't want to send ViewerStats
	if(1) return;
	// </edit>
	// IW 9/23/02 I elected not to move this into LLViewerStats
	// because it depends on too many viewer.cpp globals.
	// Someday we may want to merge all our stats into a central place
	// but that day is not today.

	// Only send stats if the agent is connected to a region.
	if (!gAgent.getRegion() || gNoRender)
	{
		return;
	}

	LLSD body;
	std::string url = gAgent.getRegion()->getCapability("ViewerStats");

	if (url.empty()) {
		llwarns << "Could not get ViewerStats capability" << llendl;
		return;
	}
	
	body["session_id"] = gAgentSessionID;
	
	LLSD &agent = body["agent"];
	
	time_t ltime;
	time(&ltime);
	F32 run_time = F32(LLFrameTimer::getElapsedSeconds());

	agent["start_time"] = S32(ltime - S32(run_time));

	// The first stat set must have a 0 run time if it doesn't actually
	// contain useful data in terms of FPS, etc.  We use half the
	// SEND_STATS_PERIOD seconds as the point at which these statistics become
	// valid.  Data warehouse uses a 0 value here to easily discard these
	// records with non-useful FPS values etc.
	if (run_time < (SEND_STATS_PERIOD / 2))
	{
		agent["run_time"] = 0.0f;
	}
	else
	{
		agent["run_time"] = run_time;
	}

	// send fps only for time app spends in foreground
	agent["fps"] = (F32)gForegroundFrameCount / gForegroundTime.getElapsedTimeF32();
	// <edit>
	//agent["version"] = gCurrentVersion;
	agent["version"] = gSavedSettings.getString("SpecifiedChannel");
	// </edit>
	std::string language = LLUI::getLanguage();
	agent["language"] = language;
	
	agent["sim_fps"] = ((F32) gFrameCount - gSimFrames) /
		(F32) (gRenderStartTime.getElapsedTimeF32() - gSimLastTime);

	gSimLastTime = gRenderStartTime.getElapsedTimeF32();
	gSimFrames   = (F32) gFrameCount;

	agent["agents_in_view"] = LLVOAvatar::sNumVisibleAvatars;
	agent["ping"] = gAvgSimPing;
	agent["meters_traveled"] = gAgent.getDistanceTraveled();
	agent["regions_visited"] = gAgent.getRegionsVisited();
	agent["mem_use"] = getCurrentRSS() / 1024.0;

	LLSD &system = body["system"];
	
	system["ram"] = (S32) gSysMemory.getPhysicalMemoryKB();
	system["os"] = LLAppViewer::instance()->getOSInfo().getOSStringSimple();
	system["cpu"] = gSysCPU.getCPUString();
	std::string macAddressString = llformat("%02x-%02x-%02x-%02x-%02x-%02x",
											gMACAddress[0],gMACAddress[1],gMACAddress[2],
											gMACAddress[3],gMACAddress[4],gMACAddress[5]);
	system["mac_address"] = macAddressString;
	system["serial_number"] = LLAppViewer::instance()->getSerialNumber();
	std::string gpu_desc = llformat(
		"%-6s Class %d ",
		gGLManager.mGLVendorShort.substr(0,6).c_str(),
		(S32)LLFeatureManager::getInstance()->getGPUClass())
		+ LLFeatureManager::getInstance()->getGPUString();

	system["gpu"] = gpu_desc;
	system["gpu_class"] = (S32)LLFeatureManager::getInstance()->getGPUClass();
	system["gpu_vendor"] = gGLManager.mGLVendorShort;
	system["gpu_version"] = gGLManager.mDriverVersionVendorString;

	LLSD &download = body["downloads"];

	download["world_kbytes"] = gTotalWorldBytes / 1024.0;
	download["object_kbytes"] = gTotalObjectBytes / 1024.0;
	download["texture_kbytes"] = gTotalTextureBytes / 1024.0;

	LLSD &in = body["stats"]["net"]["in"];

	in["kbytes"] = gMessageSystem->mTotalBytesIn / 1024.0;
	in["packets"] = (S32) gMessageSystem->mPacketsIn;
	in["compressed_packets"] = (S32) gMessageSystem->mCompressedPacketsIn;
	in["savings"] = (gMessageSystem->mUncompressedBytesIn -
					 gMessageSystem->mCompressedBytesIn) / 1024.0;
	
	LLSD &out = body["stats"]["net"]["out"];
	
	out["kbytes"] = gMessageSystem->mTotalBytesOut / 1024.0;
	out["packets"] = (S32) gMessageSystem->mPacketsOut;
	out["compressed_packets"] = (S32) gMessageSystem->mCompressedPacketsOut;
	out["savings"] = (gMessageSystem->mUncompressedBytesOut -
					  gMessageSystem->mCompressedBytesOut) / 1024.0;

	LLSD &fail = body["stats"]["failures"];

	fail["send_packet"] = (S32) gMessageSystem->mSendPacketFailureCount;
	fail["dropped"] = (S32) gMessageSystem->mDroppedPackets;
	fail["resent"] = (S32) gMessageSystem->mResentPackets;
	fail["failed_resends"] = (S32) gMessageSystem->mFailedResendPackets;
	fail["off_circuit"] = (S32) gMessageSystem->mOffCircuitPackets;
	fail["invalid"] = (S32) gMessageSystem->mInvalidOnCircuitPackets;

	// Misc stats, two strings and two ints
	// These are not expecticed to persist across multiple releases
	// Comment any changes with your name and the expected release revision
	// If the current revision is recent, ping the previous author before overriding
	LLSD &misc = body["stats"]["misc"];

	// Screen size so the UI team can figure out how big the widgets
	// appear and use a "typical" size for end user tests.

	S32 window_width = gViewerWindow->getWindowDisplayWidth();
	S32 window_height = gViewerWindow->getWindowDisplayHeight();
	S32 window_size = (window_width * window_height) / 1024;
	misc["string_1"] = llformat("%d", window_size);
	// misc["string_2"] = 
// 	misc["int_1"] = LLFloaterDirectory::sOldSearchCount; // Steve: 1.18.6
// 	misc["int_2"] = LLFloaterDirectory::sNewSearchCount; // Steve: 1.18.6
// 	misc["int_1"] = LLSD::Integer(gSavedSettings.getU32("RenderQualityPerformance")); // Steve: 1.21
// 	misc["int_2"] = LLSD::Integer(gFrameStalls); // Steve: 1.21

	F32 unbaked_time = LLVOAvatar::sUnbakedTime * 1000.f / gFrameTimeSeconds;
	misc["int_1"] = LLSD::Integer(unbaked_time); // Steve: 1.22
	F32 grey_time = LLVOAvatar::sGreyTime * 1000.f / gFrameTimeSeconds;
	misc["int_2"] = LLSD::Integer(grey_time); // Steve: 1.22

	llinfos << "Misc Stats: int_1: " << misc["int_1"] << " int_2: " << misc["int_2"] << llendl;
	llinfos << "Misc Stats: string_1: " << misc["string_1"] << " string_2: " << misc["string_2"] << llendl;
	
	LLViewerStats::getInstance()->addToMessage(body);
	LLHTTPClient::post(url, body, new ViewerStatsResponder());
}
예제 #8
0
파일: test.c 프로젝트: homingway/hickwall
int main(){
  printf("PeakRSS: %dK, CurrentRSS: %dK\n", getPeakRSS()/1024, getCurrentRSS()/1024);
}
예제 #9
0
size_t MemoryStatistics::currentMemoryUsage()
{
    return getCurrentRSS();
}
예제 #10
0
파일: toabout.cpp 프로젝트: doniexun/tora
toAbout::toAbout(QWidget* parent, const char* name, bool modal)
    : QDialog(parent)
{
    if (name)
        setObjectName(name);
    if (modal)
        setWindowModality(Qt::WindowModal);

    setupUi(this);

#if !defined(TOBUILDTYPE_RELEASE)
    setWindowTitle(QString(TOAPPNAME) + " " BUILD_TAG);
#endif

    // About Tab
    {
    	QFile f(":/widgets/toabout.html");
    	f.open(QFile::ReadOnly);
    	QString AboutText = QString::fromUtf8(f.readAll());
    	QString buffer = AboutText.arg(QString::fromLatin1(TORAVERSION));
    	textBrowserAbout->setHtml(buffer);
    }

    // License Tab
    {
    	QFile f(":/widgets/gpl-2.0-standalone.html");
    	f.open(QFile::ReadOnly);
    	QString LicenseText = QString::fromUtf8(f.readAll());
    	textBrowserLicense->setHtml(LicenseText);
    }

	// Copyright Tab
	{

	}

	// Version Tab
	{
		QString version;
#if defined(HAVE_GITREVISION_H)
		version.append("<center><table>");
		QString format = QString("<tr><td align=\"right\">%1:<td align=\"left\">%2");
		version.append(format.arg("GITVERSION").arg(GITVERSION));
		version.append(format.arg("GITVERSION_MAJOR").arg(GITVERSION_MAJOR));
		version.append(format.arg("GITVERSION_MINOR").arg(GITVERSION_MINOR));
		version.append(format.arg("GIT_BUILD_TYPE").arg(GIT_BUILD_TYPE));
		version.append(format.arg("GITVERSION_COUNT").arg(GITVERSION_COUNT));
		version.append(format.arg("GITVERSION_SHA1").arg(GITVERSION_SHA1));
		version.append(format.arg("GITVERSION_SHORT").arg(GITVERSION_SHORT));
		version.append(format.arg("GIT_BRANCH").arg(GIT_BRANCH));
		version.append(format.arg("BUILD_TAG").arg(BUILD_TAG));
		version.append(format.arg("BUILD_DATE").arg(BUILD_DATE));
		version.append("</table>");
#else
		version = TORAVERSION;
#endif
		QFont fixed(Utils::toStringToFont(toConfigurationNewSingle::Instance().option(ToConfiguration::Editor::ConfCodeFont).toString()));
		textBrowserVersion->setFont(fixed);
		textBrowserUpdate->setFont(fixed);
		textBrowserVersion->setHtml(version);

#if defined(Q_OS_WIN32)
		toUpdater &tu = toUpdaterSingle::Instance();
		connect(&tu, SIGNAL(updatingChanged(QString)), this, SLOT(updateVersionTab(QString)));
		connect(&tu, SIGNAL(updatingFinished(QString)), this, SLOT(updateVersionTab(QString)));
		connect(updateButton, SIGNAL(clicked()), &tu, SLOT(check()));
#endif
	}


	// Memory tab
#ifdef TORA_EXPERIMENTAL
	{
		QString usage("Memory usage: %1 M");
		textBrowserMemory->setPlainText(usage.arg(QString::number((qulonglong)getCurrentRSS())));
	}
#else
#endif

}