1// Printing memory profiling only works in the configuration where we can 2// detect leaks. 3// REQUIRES: leak-detection 4// 5// RUN: %clangxx_asan %s -o %t 6// RUN: %run %t 2>&1 | FileCheck %s 7#include <sanitizer/common_interface_defs.h> 8 9#include <stdio.h> 10 11char *sink[1000]; 12 13int main() { 14 int idx = 0; 15 for (int i = 0; i < 17; i++) 16 sink[idx++] = new char[131000]; 17 for (int i = 0; i < 28; i++) 18 sink[idx++] = new char[24000]; 19 20 __sanitizer_print_memory_profile(100); 21 __sanitizer_print_memory_profile(50); 22} 23 24// CHECK: Live Heap Allocations: {{.*}}; showing top 100% 25// CHECK: 2227000 byte(s) ({{.*}}%) in 17 allocation(s) 26// CHECK: 672000 byte(s) ({{.*}}%) in 28 allocation(s) 27// CHECK: Live Heap Allocations: {{.*}}; showing top 50% 28// CHECK: 2227000 byte(s) ({{.*}}%) in 17 allocation(s) 29// CHECK-NOT: 1008 byte 30