brintos

brintos / llvm-project-archived public Read only

0
0
Text · 716 B · 3f8ad46 Raw
33 lines · cpp
1// Tests heap_profile=1.2// Printing memory profiling only works in the configuration where we can3// detect leaks.4// REQUIRES: leak-detection5//6// RUN: %clangxx_asan %s -o %t7// RUN: %env_asan_opts=heap_profile=1 %run %t 2>&1 | FileCheck %s8#include <sanitizer/common_interface_defs.h>9 10#include <stdio.h>11#include <string.h>12#include <unistd.h>13 14char *sink[1000];15 16int main() {17 18  for (int i = 0; i < 3; i++) {19    const size_t  kSize = 13000000;20    char *x = new char[kSize];21    memset(x, 0, kSize);22    sink[i] = x;23    sleep(1);24  }25}26 27// CHECK: HEAP PROFILE at RSS28// CHECK: 13000000 byte(s)29// CHECK: HEAP PROFILE at RSS30// CHECK: 26000000 byte(s)31// CHECK: HEAP PROFILE at RSS32// CHECK: 39000000 byte(s)33