June 2018
Intermediate to advanced
316 pages
6h 34m
English
An operating system has several resources that are limited in number, for instance, files or internet sockets. A resource leak is a situation where a computer program doesn't release the resources it has acquired. The most common example is a case where files have been opened but haven't been closed:
fun readFirstLine() : String { val fileInputStream = FileInputStream("input.txt") val inputStreamReader = InputStreamReader(fileInputStream) val bufferedReader = BufferedReader(inputStreamReader) return bufferedReader.readLine()}
In the preceding code snippet, the input.txt file hasn't been closed after being acquired and used. InputStream is an abstract superclass of all classes representing an input stream of bytes. It implements ...
Read now
Unlock full access