The Code Leads to VmSize Increase

1 Description

VmSize is the Virtual memory usage of the entire process. It's the sume of
all mapped memory (/proc/pid/maps)

2 Code Sample

the samples below will increase VmSize, indeed they are all bugs.

2.1 malloc without free

static void LeakTest() {
  char* msg = (char*) malloc(128);
  sprintf(msg, "hello\n");

2.2 open file without close

static void OpenFileWithoutClose() {
  FILE *fp;

  fp = fopen("/tmp/a.1", "a+");
  if (fp) {
    fputs("hello\n", fp);