[bisq-network/bisq] Prevent memory leak in CandleStickChart & VolumeChart (#3914)

Steven Barclay notifications at github.com
Wed Jan 22 10:53:26 UTC 2020


<!-- 
- make yourself familiar with the CONTRIBUTING.md if you have not already (https://github.com/bisq-network/bisq/blob/master/CONTRIBUTING.md)
- make sure you follow our [coding style guidelines][https://github.com/bisq-network/style/issues)
- pick a descriptive title
- provide some meaningful PR description below
- create the PR
- in case you receive a "Change request" and/or a NACK, please react within 30 days. If not, we will close your PR and it can not be up for compensation.
- After addressing the change request, __please re-request a review!__ Otherwise we might miss your PR as we tend to only look at pull requests tagged with a "review required".
-->

Ensure that the superclass methods `XYChart.removeDataItemFromDisplay` and `XYChart.removeSeriesFromDisplay` are always called from the implemented `dataItemRemoved` and `seriesRemoved` methods respectively, as specified by the API javadoc.

This prevents a leak of old `Candle` and `VolumeBar` objects every time the trades charts view is updated. The former is quite substantial, as each Candle object has a retained size of about 70kB and there are up to 90 candlesticks / volume bars leaked per chart update.

--

By cycling through the _Month_, _Week_ and _Day_ interval a few dozen times, the following heap usage stats were obtained using JProfiler:

![Screenshot from 2020-01-22 10-42-19](https://user-images.githubusercontent.com/54855381/72887622-fd2cf680-3d03-11ea-9404-9e97f04a74a1.png)

I believe updates to the two charts happen periodically as long as the trades charts view is selected, as it appeared to leak while unattended as well. I haven't had a chance to measure the rate, though.
You can view, comment on, or merge this pull request online at:

  https://github.com/bisq-network/bisq/pull/3914

-- Commit Summary --

  * Prevent memory leak in CandleStickChart & VolumeChart

-- File Changes --

    M desktop/src/main/java/bisq/desktop/main/market/trades/charts/price/CandleStickChart.java (17)
    M desktop/src/main/java/bisq/desktop/main/market/trades/charts/volume/VolumeChart.java (23)

-- Patch Links --

https://github.com/bisq-network/bisq/pull/3914.patch
https://github.com/bisq-network/bisq/pull/3914.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/bisq-network/bisq/pull/3914
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20200122/2e941be1/attachment-0001.html>


More information about the bisq-github mailing list