提交 3d622cdd 编写于 作者: N nroskill 提交者: wangzelin.wzl

fix get_virtual_memory_used core in arm

上级 53f7a648
......@@ -461,7 +461,7 @@ int main(int argc, char* argv[])
if (0 == memory_used) {
_LOG_INFO("Get virtual memory info failed");
} else {
_LOG_INFO("Virtual memory : %ld byte", memory_used);
_LOG_INFO("Virtual memory : %'15ld byte", memory_used);
}
// print in log file.
print_args(argc, argv);
......
......@@ -10,6 +10,7 @@
* See the Mulan PubL v2 for more details.
*/
#include <cstdio>
#include "lib/utility/ob_print_utils.h"
#include "lib/alloc/malloc_hook.h"
#include "share/ob_tenant_mgr.h"
......@@ -26,20 +27,13 @@
int64_t get_virtual_memory_used()
{
constexpr int BUFFER_SIZE = 128;
char buf[BUFFER_SIZE];
snprintf(buf, BUFFER_SIZE, "/proc/%d/status", getpid());
std::ifstream status(buf);
int64_t used = 0;
while (status && 0 == used) {
status >> buf;
if (strncmp(buf, "VmSize:", BUFFER_SIZE) == 0) {
status >> buf;
used = std::stoi(buf);
} else {
status.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
}
}
return used * 1024;
char filename[BUFFER_SIZE];
int64_t page_cnt = 0;
snprintf(filename, BUFFER_SIZE, "/proc/%d/statm", getpid());
FILE* statm = fopen(filename, "r");
fscanf(statm, "%ld", &page_cnt);
fclose(statm);
return page_cnt * sysconf(_SC_PAGESIZE);
}
namespace oceanbase {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册