1 // Printing memory profiling only works in the configuration where we can
3 // REQUIRES: leak-detection
5 // RUN: %clangxx_asan %s -o %t
6 // RUN: %run %t 100 10 2>&1 | FileCheck %s --check-prefix=CHECK-100-10
7 // RUN: %run %t 100 1 2>&1 | FileCheck %s --check-prefix=CHECK-100-1
8 // RUN: %run %t 50 10 2>&1 | FileCheck %s --check-prefix=CHECK-50-10
9 #include <sanitizer/common_interface_defs.h>
16 int main(int argc
, char **argv
) {
21 for (int i
= 0; i
< 17; i
++)
22 sink
[idx
++] = new char[131000];
23 for (int i
= 0; i
< 28; i
++)
24 sink
[idx
++] = new char[24000];
26 __sanitizer_print_memory_profile(atoi(argv
[1]), atoi(argv
[2]));
29 // CHECK-100-10: Live Heap Allocations: {{.*}}; showing top 100% (at most 10 unique contexts)
30 // CHECK-100-10: 2227000 byte(s) ({{.*}}%) in 17 allocation(s)
31 // CHECK-100-10: 672000 byte(s) ({{.*}}%) in 28 allocation(s)
33 // CHECK-100-1: Live Heap Allocations: {{.*}}; showing top 100% (at most 1 unique contexts)
34 // CHECK-100-1: 2227000 byte(s) ({{.*}}%) in 17 allocation(s)
35 // CHECK-100-1-NOT: allocation
37 // CHECK-50-10: Live Heap Allocations: {{.*}}; showing top 50% (at most 10 unique contexts)
38 // CHECK-50-10: 2227000 byte(s) ({{.*}}%) in 17 allocation(s)
39 // CHECK-50-10-NOT: allocation