The Hidden Environmental Cost of Poor Coding Practices in TensorFlow and Keras Applications: A Study on Resource Leaks and Carbon Emissions

📅 2026-06-18
📈 Citations: 0
Influential: 0
📄 PDF
🤖 AI Summary
This study addresses the lack of empirical quantification regarding energy waste and carbon emissions caused by resource leaks—specifically improper model reuse (IMR) and unreleased tensor references (UTR)—in machine learning applications. Through controlled experiments integrating energy consumption and carbon emission estimation models with paired statistical tests, this work presents the first systematic evaluation of the environmental impact of these two leak types in TensorFlow/Keras training tasks. The findings demonstrate that IMR and UTR lead to approximately 32% and 46% increases in electricity consumption, respectively, accompanied by statistically significant rises in carbon emissions. These results substantiate that resource leaks exert a considerable negative effect on the energy efficiency of machine learning workflows.
📝 Abstract
Efficiency and sustainability are critical considerations in the development and deployment of machine learning (ML) applications. Among the factors influencing sustainability, resource leaks in ML code can introduce hidden inefficiencies that elevate energy consumption and CO2 emissions. Despite this, empirical evidence quantifying their environmental impact remains limited. This emerging results paper presents an initial empirical investigation of two common resource-leak smells, namely Improper Model Reuse (IMR) and Unreleased Tensor References (UTR), and their impact on energy consumption and CO2 emissions in TensorFlow and Keras workloads. Controlled experiments were conducted for each smell by executing identical training tasks while comparing against a smell-free baseline. Our preliminary results show that both smells consistently increase estimated electricity usage and carbon emissions. IMR and UTR increased electricity consumption by approximately 32% and 46%, respectively, with proportional increases in CO2 emissions. Paired statistical tests indicate that these differences are systematic and statistically significant, providing initial empirical evidence that resource-leak smells may degrade ML energy efficiency and environmental sustainability. These findings suggest that resource-leak smells pose measurable risks to both software quality and sustainability, emphasizing the importance of integrating resource-lifecycle management and energy-efficiency considerations into ML development.
Problem

Research questions and friction points this paper is trying to address.

resource leaks
carbon emissions
energy consumption
TensorFlow
Keras
Innovation

Methods, ideas, or system contributions that make the work stand out.

resource leaks
energy efficiency
carbon emissions
machine learning sustainability
code smells