0

So I am actually seeking for suggested list of causes that may cause my java program to get slower overtime.

My java program keeps reading lines (line by line) from files and then for each line it applies the same set of calculation over it. However the issue as mentioned earlier is that it performance gets slower over time.

Now the drop in performance is not linear meaning that it does not keep slowing down every second. The performance (The speed of reading mainly) drops all at once. After applying a certain function that takes action periodically (Every couple of minutes or so).

Now the first thing that should jump to your mind that this function is doing some of the most obvious actions for performance reduction like

1- Creating large number of objects that stays in memory
    a) Number of object is minimized
    b) Each object reference is set to null when not needed to allow the GC (Garbage Collector) to perform well
    c) I checked on task manager an it shows that memory usage is normal (Because of what I have done)
    d) I check the heap usage on visalVM also and the usage of the heap was normal and low.

2- I am reading a large number of files, so not closing the files might be the reason
    a) I made sure that all the opened files are closed after reading them.

I tried to figure out if any of the computer resources are enormously consumed over time, however using the task manager and the VisalVM 1.3.8 I couldn't find any.

Besides the fact the GC is behaving normally, where there are no trash in memory that might be affecting the performance and needs to be removed.

So do you have any suggestion of what cause that issue.

Abdelrahman Shoman
  • 2,882
  • 7
  • 36
  • 61
  • try to flush the buffer – Jean-François Savard Feb 16 '15 at 17:41
  • What are you actually doing? Can you post some code for us to try and figure out? Can you write a reproduction of your problem? – Reut Sharabani Feb 16 '15 at 17:42
  • 2
    We need to see proper code to evaluate what may happen. Use another profiler to evaluate your system as well. – Luiggi Mendoza Feb 16 '15 at 17:42
  • @Jean-FrançoisSavard what is the point of flushing the buffer If I am already closing it ? – Abdelrahman Shoman Feb 16 '15 at 17:51
  • @Abdel-RahmanShoman We have no example, maybe you read so much lines before closing it that it causes the program to become slow. Flushing it after a certain number of read may help. – Jean-François Savard Feb 16 '15 at 17:54
  • @Jean-FrançoisSavard Ok now it make sense. However the size of all files are identical. So if they didn't slow the performance at the beginning why would it do so now – Abdelrahman Shoman Feb 16 '15 at 17:58
  • You said you're using visualvm, but what did you profile? If it's a CPU-bound task *something* interesting should show up in the CPU profiling results. Also, how much slowdown are we talking here? And have you tried to postpone that periodic action? – the8472 Feb 16 '15 at 19:16

0 Answers0