From: srit Date: Fri, 4 Mar 2011 23:56:37 +0000 (+0000) Subject: Remove statgrab stuff, prefer portable ITK functions X-Git-Tag: v1.2.0~195 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=8365018304075da6b6ef5ab04ffc47660c77d05f;p=clitk.git Remove statgrab stuff, prefer portable ITK functions --- diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 2060486..c809743 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -37,16 +37,6 @@ SET(clitkCommon_SRC ### Declare clitkCommon library ADD_LIBRARY(clitkCommon STATIC ${clitkCommon_SRC}) -### if LIBSTATGRAB is installed, add clitkMemoryUsage.cxx in the library -IF(CLITK_MEMORY_INFO) - FIND_PROGRAM(LIBSTATGRAB NAMES statgrab PATHS) - IF (${LIBSTATGRAB} MATCHES "LIBSTATGRAB-NOTFOUND") - MESSAGE( FATAL_ERROR "libstatgrab NOT FOUND -> please install http://www.i-scream.org/libstatgrab/") - ELSE (${LIBSTATGRAB} MATCHES "LIBSTATGRAB-NOTFOUND") - TARGET_LINK_LIBRARIES(clitkCommon statgrab) - ENDIF (${LIBSTATGRAB} MATCHES "LIBSTATGRAB-NOTFOUND") -ENDIF(CLITK_MEMORY_INFO) - TARGET_LINK_LIBRARIES(clitkCommon vtkCommon vtkImaging vtkHybrid ITKBasicFilters) ADD_LIBRARY(clitkDicomRTStruct STATIC diff --git a/common/clitkMemoryUsage.cxx b/common/clitkMemoryUsage.cxx index 8ceff61..7e0079e 100644 --- a/common/clitkMemoryUsage.cxx +++ b/common/clitkMemoryUsage.cxx @@ -20,6 +20,9 @@ #include "clitkCommon.h" #include "clitkMemoryUsage.h" +// itk include +#include "itkMemoryUsageObserver.h" + void clitk::PrintMemory(bool verbose, std::string s) { #if CLITK_MEMORY_INFO == 1 @@ -29,25 +32,13 @@ void clitk::PrintMemory(bool verbose, std::string s) if (s != "") std::cout << "==> " << s << ": "; std::cout << mem << "MB (" << mem-previous << "MB)" << std::endl; previous = mem; - //DD(stat[i].proc_resident/1000/1000); - //DD(stat[i].pid); } #endif - } +} double clitk::GetMemoryUsageInMb() { -#if CLITK_MEMORY_INFO == 1 - //sleep(1); // wait to refresh memory ? need to let the system refresh the mem - int * entries = new int; - sg_process_stats * stat = new sg_process_stats; - int i=0; - stat = sg_get_process_stats(entries); - // Search the current pid in the list of processes - while (stat[i].pid != getpid()) i++; - // Display total memory size - double mem = stat[i].proc_resident/1024/1024; // in Mb - return mem; -#endif - } + itk::MemoryUsageObserver memUsage; + return memUsage.GetMemoryUsage() / 1024.; +} diff --git a/common/clitkMemoryUsage.h b/common/clitkMemoryUsage.h index 38a982e..a0dc865 100644 --- a/common/clitkMemoryUsage.h +++ b/common/clitkMemoryUsage.h @@ -22,11 +22,6 @@ // clitk include #include "clitkConfiguration.h" -// statgrab include -#if CLITK_MEMORY_INFO == 1 -#include -#endif - //-------------------------------------------------------------------- namespace clitk {