Supriya Ghosh (Editor)

Code cleanup

Updated on
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit

Code cleanup refers to the act of writing code so that it cleans up leftover data structures and other unwanted materials from memory and the filesystem. It is not the same as refactoring code, which involves making the source code itself easier to understand, maintain, and modify.



In C++, code cleanup involves deallocating previously allocated dynamic memory.

This is usually done with the C++ delete and delete[] operations.


In Python 3, explicit deletion of variables requires the del keyword.


In JavaScript, deleting a variable requires the delete keyword.


In Java, variables cannot be truly deleted. The most that can be done is to set the variable to null, which works with any Java object, including arrays.

Other Meanings

Code cleanup can also refer to the removal of all comments from source code, or the act of removing temporary files after a program has finished executing.

For instance, in a web browser such as Google Chrome or Maxthon, code must be written in order to clean up files such as cookies and HTML5 storage. The deletion of temporary files is similar to the deletion of unneeded lists and arrays of data. However, a file is treated as a permanent way to store a resizable list of bytes, and can also be removed from existence.

Loop Cleanup

Another technical term sometimes called "code cleanup" is loop cleanup.


Code cleanup Wikipedia

Similar Topics
Rebel in Paradise
Nic Mayhew
Amit Sheth