1 // Tests heap_profile=1. 2 // Printing memory profiling only works in the configuration where we can 3 // detect leaks. 4 // REQUIRES: leak-detection 5 // 6 // RUN: %clangxx_asan %s -o %t 7 // RUN: %env_asan_opts=heap_profile=1 %run %t 2>&1 | FileCheck %s 8 #include <sanitizer/common_interface_defs.h> 9 10 #include <stdio.h> 11 #include <string.h> 12 #include <unistd.h> 13 14 char *sink[1000]; 15 main()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 RSS 28 // CHECK: 13000000 byte(s) 29 // CHECK: HEAP PROFILE at RSS 30 // CHECK: 26000000 byte(s) 31 // CHECK: HEAP PROFILE at RSS 32 // CHECK: 39000000 byte(s) 33