2 * Copyright 2013 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include <sys/types.h>
25 #include <heap-monitor.h>
28 static char execpath[4096];
30 int destructor(void) __attribute__((destructor));
31 int constructor(void) __attribute__((constructor));
33 void (*__malloc_initialize_hook)(void) = heap_monitor_init;
39 snprintf(execpath, sizeof(execpath), "/proc/%d/cmdline", getpid());
41 fd = open(execpath, O_RDONLY);
44 len = read(fd, execpath, sizeof(execpath));
47 printf("execpath: [%s]\n", execpath);
49 heap_monitor_add_target("");
52 printf("open: %s\n", strerror(errno));
60 if (strlen(execpath)) {
64 usage = heap_monitor_target_usage("");
65 heap_monitor_del_target("");
67 printf("execpath: [%s]\n", execpath);
68 printf("Leak: %d\n", usage);