dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #26065
Fwd: [Branch ~dolfin-core/dolfin/trunk] Rev 7037: Use long unsigned int for number of bytes used by memory usage
---------- Forwarded message ----------
From: <noreply@xxxxxxxxxxxxx>
Date: Sat, Oct 27, 2012 at 1:27 AM
Subject: [Branch ~dolfin-core/dolfin/trunk] Rev 7037: Use long
unsigned int for number of bytes used by memory usage
Would std::size_t be more appropriate?
Garth
------------------------------------------------------------
revno: 7037
committer: Anders Logg <logg@glaurung>
branch nick: trunk-logg
timestamp: Fri 2012-10-26 17:25:10 -0700
message:
Use long unsigned int for number of bytes used by memory usage
monitor to avoid overflow
modified:
ChangeLog
dolfin/log/Logger.cpp
dolfin/log/Logger.h
--
lp:dolfin
https://code.launchpad.net/~dolfin-core/dolfin/trunk
Your team DOLFIN Core Team is subscribed to branch lp:dolfin.
To unsubscribe from this branch go to
https://code.launchpad.net/~dolfin-core/dolfin/trunk/+edit-subscription
=== modified file 'ChangeLog'
--- ChangeLog 2012-10-26 04:16:29 +0000
+++ ChangeLog 2012-10-27 00:25:10 +0000
@@ -1,4 +1,5 @@
1.1.0 [not yet released]
+ - Add memory usage monitor: monitor_memory_usage()
- Compare mesh hash in interpolate_vertex_values
- Add hash() for Mesh and MeshTopology
- Expose GenericVector::operator{+=,-=,+,-}(double) to Python
=== modified file 'dolfin/log/Logger.cpp'
--- dolfin/log/Logger.cpp 2012-10-27 00:04:58 +0000
+++ dolfin/log/Logger.cpp 2012-10-27 00:25:10 +0000
@@ -61,7 +61,7 @@
// Get process ID and page size
const dolfin::uint pid = getpid();
- const dolfin::uint page_size = getpagesize();
+ const long unsigned int page_size = getpagesize();
// Print some info
std::stringstream s;
@@ -83,12 +83,12 @@
statm.open(filename.str().c_str());
if (!statm)
logger->error("Unable to open statm file for process.");
- dolfin::uint num_pages;
+ long unsigned int num_pages;
statm >> num_pages;
statm.close();
// Convert to MB and report memory usage
- const dolfin::uint num_mb = num_pages*page_size / (1024*1024);
+ const long unsigned int num_mb = num_pages*page_size / (1024*1024);
logger->_report_memory_usage(num_mb);
}
}
@@ -348,13 +348,13 @@
#endif
}
//-----------------------------------------------------------------------------
-void Logger::_report_memory_usage(uint num_mb)
+void Logger::_report_memory_usage(long unsigned int num_mb)
{
std::stringstream s;
s << "Memory usage: " << num_mb << " MB";
log(s.str());
_maximum_memory_usage = std::max(_maximum_memory_usage,
- static_cast<int>(num_mb));
+ static_cast<long int>(num_mb));
}
//-----------------------------------------------------------------------------
void Logger::__debug(std::string msg) const
=== modified file 'dolfin/log/Logger.h'
--- dolfin/log/Logger.h 2012-10-27 00:04:58 +0000
+++ dolfin/log/Logger.h 2012-10-27 00:25:10 +0000
@@ -105,7 +105,7 @@
void monitor_memory_usage();
/// Helper function for reporting memory usage
- void _report_memory_usage(uint num_mb);
+ void _report_memory_usage(long unsigned int num_mb);
/// Helper function for dolfin_debug macro
void __debug(std::string msg) const;
@@ -142,7 +142,7 @@
boost::thread* _thread_monitor_memory_usage;
// Maximum memory usage so far
- int _maximum_memory_usage;
+ long int _maximum_memory_usage;
};
--
Garth N. Wells
Department of Engineering, University of Cambridge
http://www.eng.cam.ac.uk/~gnw20
=== modified file 'ChangeLog'
--- ChangeLog 2012-10-26 04:16:29 +0000
+++ ChangeLog 2012-10-27 00:25:10 +0000
@@ -1,4 +1,5 @@
1.1.0 [not yet released]
+ - Add memory usage monitor: monitor_memory_usage()
- Compare mesh hash in interpolate_vertex_values
- Add hash() for Mesh and MeshTopology
- Expose GenericVector::operator{+=,-=,+,-}(double) to Python
=== modified file 'dolfin/log/Logger.cpp'
--- dolfin/log/Logger.cpp 2012-10-27 00:04:58 +0000
+++ dolfin/log/Logger.cpp 2012-10-27 00:25:10 +0000
@@ -61,7 +61,7 @@
// Get process ID and page size
const dolfin::uint pid = getpid();
- const dolfin::uint page_size = getpagesize();
+ const long unsigned int page_size = getpagesize();
// Print some info
std::stringstream s;
@@ -83,12 +83,12 @@
statm.open(filename.str().c_str());
if (!statm)
logger->error("Unable to open statm file for process.");
- dolfin::uint num_pages;
+ long unsigned int num_pages;
statm >> num_pages;
statm.close();
// Convert to MB and report memory usage
- const dolfin::uint num_mb = num_pages*page_size / (1024*1024);
+ const long unsigned int num_mb = num_pages*page_size / (1024*1024);
logger->_report_memory_usage(num_mb);
}
}
@@ -348,13 +348,13 @@
#endif
}
//-----------------------------------------------------------------------------
-void Logger::_report_memory_usage(uint num_mb)
+void Logger::_report_memory_usage(long unsigned int num_mb)
{
std::stringstream s;
s << "Memory usage: " << num_mb << " MB";
log(s.str());
_maximum_memory_usage = std::max(_maximum_memory_usage,
- static_cast<int>(num_mb));
+ static_cast<long int>(num_mb));
}
//-----------------------------------------------------------------------------
void Logger::__debug(std::string msg) const
=== modified file 'dolfin/log/Logger.h'
--- dolfin/log/Logger.h 2012-10-27 00:04:58 +0000
+++ dolfin/log/Logger.h 2012-10-27 00:25:10 +0000
@@ -105,7 +105,7 @@
void monitor_memory_usage();
/// Helper function for reporting memory usage
- void _report_memory_usage(uint num_mb);
+ void _report_memory_usage(long unsigned int num_mb);
/// Helper function for dolfin_debug macro
void __debug(std::string msg) const;
@@ -142,7 +142,7 @@
boost::thread* _thread_monitor_memory_usage;
// Maximum memory usage so far
- int _maximum_memory_usage;
+ long int _maximum_memory_usage;
};
Follow ups