From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 81B502A5E for ; Sun, 31 Dec 2017 11:12:58 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 Dec 2017 02:12:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,485,1508828400"; d="scan'208";a="17938128" Received: from unknown (HELO localhost.localdomain) ([10.224.122.203]) by fmsmga001.fm.intel.com with ESMTP; 31 Dec 2017 02:12:55 -0800 From: Vipin Varghese To: dev@dpdk.org Cc: david.hunt@intel.com, deepak.k.jain@intel.com, Vipin Varghese Date: Sun, 31 Dec 2017 21:24:01 +0530 Message-Id: <1514735641-8738-1-git-send-email-vipin.varghese@intel.com> X-Mailer: git-send-email 1.9.1 Subject: [dpdk-dev] [PATCH v1] [app/procinfo] fix memory leak - PCAP & service X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Dec 2017 10:12:58 -0000 When procinfo uses the PCAP PMD it is not detached. The library service also makes of memory but never releases at exit of application. These leads to memory leak, on multiple runs. The patch add check for libpcap PMD check and detaches the same. The patch also frees the service library memory too. Signed-off-by: Vipin Varghese --- app/proc_info/main.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/proc_info/main.c b/app/proc_info/main.c index 64fbbd0..44d9af9 100644 --- a/app/proc_info/main.c +++ b/app/proc_info/main.c @@ -58,6 +58,7 @@ #include #include #include +#include /* Maximum long option length for option parsing. */ #define MAX_LONG_OPT_SZ 64 @@ -689,5 +690,24 @@ static void collectd_resolve_cnt_type(char *cnt_type, size_t cnt_type_len, if (enable_metrics) metrics_display(RTE_METRICS_GLOBAL); + for (i = 0; i < nb_ports; i++) { + struct rte_eth_dev_info dev_info = {0}; + char name[RTE_DEV_NAME_MAX_LEN] = {0}; + + rte_eth_dev_info_get(i, &dev_info); + if (strncmp(dev_info.driver_name, "net_pcap", 8) == 0) { + printf("port: %d driver_name: %s\n", + i, dev_info.driver_name); + rte_eth_dev_stop(i); + rte_eth_dev_close(i); + + ret = rte_eth_dev_detach(i, name); + if (ret) + rte_panic("Failed to detach %s\n", name); + } + } + + rte_service_deinit(); + return 0; } -- 1.9.1