memory_usage Module

Provide some small utilty functions for trying to monitor memory use.



Contents


Functions

public function number_of_bits_in_use() result(in_use)

Try to read the number of kilobytes in use currently from /proc/self/status and return number of bits in use. Will return negative if error encountered. This gets VmHWM.

Arguments

None

Return Value integer(kind=int64)

public function peak_number_of_bits_in_use() result(in_use)

Try to read the peak number of kilobytes currently from /proc/self/status and return number of bits in use. Will return negative if error encountered. This gets VmRSS.

Arguments

None

Return Value integer(kind=int64)

private function get_status_entry(status_entry) result(val)

Try to read an integer from /proc/self/status. Returns negative if not possible to open file.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: status_entry

Return Value integer(kind=int64)

public pure function bits_to_human_readable(bits) result(human_form)

Converts the passed number of bits into a slightly more human readable form.

Arguments

Type IntentOptional Attributes Name
integer(kind=int64), intent(in) :: bits

Return Value character(len=16)


Subroutines

public subroutine print_memory_usage(show_peak, show_current, unit)

Writes current estimate of memory use and peak memory use to provided unit.

Arguments

Type IntentOptional Attributes Name
logical, intent(in), optional :: show_peak
logical, intent(in), optional :: show_current
integer, intent(in), optional :: unit

private subroutine print_status()

Internal routine which can be used for debugging. Tries to dump the contents of /proc/self/status to output_unit

Arguments

None