Java Bottleneck

I don’t know if it can be generalized to any programming languages. I usually use Java for analyzing document data, and most of my codes do very intensive computation taking up 100% CPU usage while iterating the documents a few thousand times. One execution or experiment takes almost the whole day or a couple, so the code optimization is very important to save several hours. I found out from my codes that surprisingly, memory allocation was taking more time than computation itself. Especially, it should be avoided to repeatedly allocate memory for large arrays. When Java allocates memory for an integer array or double array, the elements are initialized to be zero automatically. Considering this initialization can be done efficiently at the memory level, however, I would conclude that reserving consecutive memory space is the most time-consuming part.

Java Bottleneck

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s