MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / get_mem_free_from_meminfo

Function get_mem_free_from_meminfo

utils/Utils.cpp:252–280  ·  view source on GitHub ↗

This function returns the amount of memory free reading from /proc/meminfo * * @return The free memory in kB */

Source from the content-addressed store, hash-verified

250 * @return The free memory in kB
251 */
252uint64_t get_mem_free_from_meminfo()
253{
254 std::string line_attribute;
255 std::ifstream file_meminfo("/proc/meminfo");
256
257 if (file_meminfo.is_open())
258 {
259 while (!(file_meminfo >> line_attribute).fail())
260 {
261 //Test if is the line containing MemFree
262 if (line_attribute == "MemFree:")
263 {
264 uint64_t mem_available;
265 if (!(file_meminfo >> mem_available).fail())
266 {
267 return mem_available;
268 }
269 else
270 {
271 return 0;
272 }
273 }
274 // if it's not MemFree ignore rest of the line
275 file_meminfo.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
276 }
277 }
278 // Nothing found or an error during opening the file
279 return 0;
280}
281} // namespace utils
282} // namespace arm_compute

Callers

nothing calls this directly

Calls 1

is_openMethod · 0.45

Tested by

no test coverage detected