Tel Map

Blog

Primefaces Line Chart – Browser Out Of Memory Crash

This blog post solves an error I encountered while trying to display some data in a PrimeFaces line chart graph (Version 6.2). Each time I opened the page with the graph, the Browser crashed with an “Out of Memory” message in the console. The error always occurred in Primeface’s chart.js

It took me 1-2 hours to realize what the problem was. So I want to save you some time if you do the same mistake I did….

Here is the code I used to initialize the graph:

maxValue (an integer value) is the maximum value used for the y-Axis. What I was trying to achieve here is, that there are around 10 horizonal lines drawn in the graph. Dividing the maximum value by 10 and setting this as the tick count should do the trick.

The problem here is that if maxValue is below 10, the division results in 0.  If the tickcount is 0, the javascript runs into an endless loop, because it uses this value in a loop to increase the corresponding counter variable.

I would have expected the library to not allow this in the first place, but the solution simply is to make sure that the tick count never is 0.

So in the end it actually was my mistake, but I hope this at least helps someone else having the same problem.

If you have questions or comments, please leave a message below.

 

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *