XCharts-Team / XCharts

A charting and data visualization library for Unity. Unity数据可视化图表插件。
https://xcharts-team.github.io
MIT License
3.25k stars 560 forks source link

The TooltipHandler creates GC garbage every frame #312

Closed stefanbursuc closed 3 months ago

stefanbursuc commented 6 months ago

The commit 0990b11 introduced a regression in which the TooltipHandler makes GC Allocations every frame:

In the case where the pointer is not in the chart, both calls to ListPool<Serie>.Get() inside the function UpdateTooltipData are executed. And because the pointer is not in the chart, m_ShowTooltip is set to false in the last else clause. This makes UpdateTooltip to skip all logic and miss the chance to release the list back to the pool.

The pull request #311 tries to fix this problem.

This also make the tooltip to work again for PieCharts. The only issue that remains is that the tooltip will continue to update it's data for a PieChart even when the TriggerOn is set to Click.

Also, maybe it would be a good idea to trigger a log after a pool reaches a certain countActive/countAll big value to warn the user that there might be a problem somewhere in the code, like not releasing the object back to the pool.

Screenshot_24 Screenshot_25