Building the Right Environment to Support , Machine Learning and Deep Learning

Byte[] pdf = toPdf(file);

Here, a method creates a PDF file from some input and returns the binary PDF as a byte array. This code expects that the generated file is small enough to adjust into the available heap .

If this code can not make this 0% sure, then it is vulnerable to an out of memory condition. Moreover, if this code is running server-side, which usually means numerous parallel threads — bulk data must never be handled with byte arrays. Streams should be used and the data should be spooled to disk or a database.

File pdf = to Pdf(file);

A similar anti-pattern is to buffer streaming input from an “untrusted̶; source, such as buffering data that arrives on a network socket. If the application doesnR7;t know how much data will arrive, it must make sure that it keeps an eye on the amount of the data. If the volume of buffered data exceeds limits, an error condition (exception) should be signaled to the caller.

 

Visit the DevX Tip Bank

 



Source link
thanks you RSS link
( http://www.devx.com/DevX/-out-of-memory-.html)

LEAVE A REPLY

Please enter your comment!
Please enter your name here