fix get_virtual_memory_used core in arm
This commit is contained in:
@ -461,7 +461,7 @@ int main(int argc, char* argv[])
|
|||||||
if (0 == memory_used) {
|
if (0 == memory_used) {
|
||||||
_LOG_INFO("Get virtual memory info failed");
|
_LOG_INFO("Get virtual memory info failed");
|
||||||
} else {
|
} else {
|
||||||
_LOG_INFO("Virtual memory : %ld byte", memory_used);
|
_LOG_INFO("Virtual memory : %'15ld byte", memory_used);
|
||||||
}
|
}
|
||||||
// print in log file.
|
// print in log file.
|
||||||
print_args(argc, argv);
|
print_args(argc, argv);
|
||||||
|
|||||||
@ -10,6 +10,7 @@
|
|||||||
* See the Mulan PubL v2 for more details.
|
* See the Mulan PubL v2 for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <cstdio>
|
||||||
#include "lib/utility/ob_print_utils.h"
|
#include "lib/utility/ob_print_utils.h"
|
||||||
#include "lib/alloc/malloc_hook.h"
|
#include "lib/alloc/malloc_hook.h"
|
||||||
#include "share/ob_tenant_mgr.h"
|
#include "share/ob_tenant_mgr.h"
|
||||||
@ -26,20 +27,13 @@
|
|||||||
int64_t get_virtual_memory_used()
|
int64_t get_virtual_memory_used()
|
||||||
{
|
{
|
||||||
constexpr int BUFFER_SIZE = 128;
|
constexpr int BUFFER_SIZE = 128;
|
||||||
char buf[BUFFER_SIZE];
|
char filename[BUFFER_SIZE];
|
||||||
snprintf(buf, BUFFER_SIZE, "/proc/%d/status", getpid());
|
int64_t page_cnt = 0;
|
||||||
std::ifstream status(buf);
|
snprintf(filename, BUFFER_SIZE, "/proc/%d/statm", getpid());
|
||||||
int64_t used = 0;
|
FILE* statm = fopen(filename, "r");
|
||||||
while (status && 0 == used) {
|
fscanf(statm, "%ld", &page_cnt);
|
||||||
status >> buf;
|
fclose(statm);
|
||||||
if (strncmp(buf, "VmSize:", BUFFER_SIZE) == 0) {
|
return page_cnt * sysconf(_SC_PAGESIZE);
|
||||||
status >> buf;
|
|
||||||
used = std::stoi(buf);
|
|
||||||
} else {
|
|
||||||
status.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return used * 1024;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace oceanbase {
|
namespace oceanbase {
|
||||||
|
|||||||
Reference in New Issue
Block a user