fbpx
Wikipedia

Handle leak

A handle leak is a type of software bug that occurs when a computer program asks for a handle to a resource but does not free the handle when it is no longer used.[1] If this occurs frequently or repeatedly over an extended period of time, a large number of handles may be marked in-use and thus unavailable, causing performance problems or a crash.

The term is derived from memory leak. Handle leaks, like memory leaks, are specific instances of resource leaks.

Causes edit

One cause of a handle leak is when a programmer mistakenly believes that retrieving a handle to an entity is simply obtaining an unmanaged reference, without understanding that a count, a copy, or other operation is actually being performed. Another occurs because of poor exception handling design patterns when programmers do not consider that when an exception occurs and a sub routine is exited prematurely, the cleanup code at the end of the routine may not be executed.

An example of this might be retrieving a handle to the display device. Programmers might use this handle to check some property (e.g. querying the supported resolutions), and then simply proceed on without ever releasing the handle. If the handle was just a pointer to some data structure with no additional management, then allowing the handle to pass out of scope would not cause an issue. However, in many cases, such handles must be explicitly closed or released to avoid leaking resources associated with them; the exact requirements for what must be done with a handle varies by interface.

References edit

  1. ^ "What Is a Handle Leak? (with picture)". EasyTechJunkie. Retrieved 2022-11-11.


handle, leak, this, article, needs, additional, citations, verification, please, help, improve, this, article, adding, citations, reliable, sources, unsourced, material, challenged, removed, find, sources, news, newspapers, books, scholar, jstor, december, 200. This article needs additional citations for verification Please help improve this article by adding citations to reliable sources Unsourced material may be challenged and removed Find sources Handle leak news newspapers books scholar JSTOR December 2009 Learn how and when to remove this template message A handle leak is a type of software bug that occurs when a computer program asks for a handle to a resource but does not free the handle when it is no longer used 1 If this occurs frequently or repeatedly over an extended period of time a large number of handles may be marked in use and thus unavailable causing performance problems or a crash The term is derived from memory leak Handle leaks like memory leaks are specific instances of resource leaks Causes editOne cause of a handle leak is when a programmer mistakenly believes that retrieving a handle to an entity is simply obtaining an unmanaged reference without understanding that a count a copy or other operation is actually being performed Another occurs because of poor exception handling design patterns when programmers do not consider that when an exception occurs and a sub routine is exited prematurely the cleanup code at the end of the routine may not be executed An example of this might be retrieving a handle to the display device Programmers might use this handle to check some property e g querying the supported resolutions and then simply proceed on without ever releasing the handle If the handle was just a pointer to some data structure with no additional management then allowing the handle to pass out of scope would not cause an issue However in many cases such handles must be explicitly closed or released to avoid leaking resources associated with them the exact requirements for what must be done with a handle varies by interface References edit What Is a Handle Leak with picture EasyTechJunkie Retrieved 2022 11 11 nbsp This computer programming related article is a stub You can help Wikipedia by expanding it vte Retrieved from https en wikipedia org w index php title Handle leak amp oldid 1121630413, wikipedia, wiki, book, books, library,

article

, read, download, free, free download, mp3, video, mp4, 3gp, jpg, jpeg, gif, png, picture, music, song, movie, book, game, games.