Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataTable: memory leak when data updated continuously #4656

Closed
ensonakamura opened this issue Jul 14, 2023 · 34 comments
Closed

DataTable: memory leak when data updated continuously #4656

ensonakamura opened this issue Jul 14, 2023 · 34 comments
Assignees
Labels
Type: Performance Issue is performance or optimization related
Milestone

Comments

@ensonakamura
Copy link

ensonakamura commented Jul 14, 2023

Experiencing severe memory leaks leading to crashes in a DataTable-heavy app.

The DataTable is loaded with 20-30 columns and 50+ rows. Some of the rows data is frequently updated (every few seconds).

Minimal Reproducible Example:

PrimeReact version

9.6.0

React version

18.x

Language

JavaScript & TypeScript

Build / Runtime

Create React App (CRA)

Steps to reproduce the behaviour

  1. Go to the Minimal Reproducible Example application: https://prime-react-data-table-issue.vercel.app/
  2. Open devtools > Memory tab and watch the memory consumption grow rapidly ( it exceeds 1GB within a few minutes and keeps going until the application crashes)

Expected behaviour

Memory consumption should not grow this rapidly and indefinitely.

The application should not crash.

image

@ensonakamura ensonakamura added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Jul 14, 2023
@melloware melloware added Type: Performance Issue is performance or optimization related and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Jul 14, 2023
@gsushant
Copy link

We are also facing same issue. Pages where we use Datatable is exponentially increasing the heap size. We have signage applications which run constantly and after our release we started noticing web pages were creashing after 2-3 hours. Had to rollback everything and now after commenting out Datatable element we are noticing the heap size is normal. Can someone please take this on priority?

@melloware
Copy link
Member

Just to ask a follow up question do either of you know when this behavior started?

Was it with the 9.0+ Version or has it been happening since v6 v7 v8 etc? Just trying to figure out if this is a newer bug and when it started.

@t-works
Copy link

t-works commented Jul 16, 2023

This was introduced in version 9.0 beta.
In 8.x it works fine. We have a production app using large data set updated via websocket that got this problem after upgrading to current version. Trying to fid out how far we need to downgrade we traced it appeared in 9 beta.

@melloware
Copy link
Member

@t-works thank you that is very helpful information.

@gsushant
Copy link

Just to ask a follow up question do either of you know when this behavior started?

Was it with the 9.0+ Version or has it been happening since v6 v7 v8 etc? Just trying to figure out if this is a newer bug and when it started.

For us it started happening when did a prod release with npm install on July 12th. That time our package.json had: "primereact": "^9.2.0". Next day while debugging the issue we even updated t0 "primereact": "^9.6.0" and it was still happening.

Now if we force 9.2.0 ("primereact": "9.2.0" in package.json) the memory leak doesnt happen..

@ensonakamura
Copy link
Author

@melloware
We first detected the memory leak issue when we updated our package to "^9.5.0" (June 30th).

Given that version 9.6 was already available at that time, this was the version installed. I can confirm that we didn't encounter this problem in version 8.7.2 or in any versions before that.

I've run tests on all versions post 8.7.2 using my Minimal Reproducible Example. Based on these tests, it appears that the bug was introduced in version 9.6 but more tests are needed on our actual application to definitively confirm this.

@melloware
Copy link
Member

melloware commented Jul 17, 2023

@ensonakamura from your reproducer it looks like the thing hogging all the memory is the System Context:

image

in 9.6.0 a new PrimeReactProvider and PrimeReactContext was added and I have a feeling that is what is causing this new misbehavior.

See: https://github.com/primefaces/primereact/blob/master/components/lib/api/PrimeReactContext.js

@t-works
Copy link

t-works commented Jul 17, 2023

Yep sorry that is correct. Our methodology was wrong. It was introduced in 9.6

@melloware melloware added this to the 9.6.1 milestone Jul 17, 2023
@gsushant
Copy link

gsushant commented Aug 2, 2023

Hi, I see 9.6.1 was released last night, can anyone please confirm if this has been fixed?

@melloware
Copy link
Member

It has not been fixed in 9.6.1 as you can see this ticket is still open.

@melloware melloware modified the milestones: 10.0.0, 11.0.0 Sep 24, 2023
@cagataycivici cagataycivici modified the milestones: 11.0.0, 10.0.3 Oct 7, 2023
@cagataycivici
Copy link
Member

Setting target milestone as 10.0.3.

@habubey habubey modified the milestones: 10.0.3, 10.0.4 Oct 11, 2023
@mertsincan
Copy link
Member

Hi @ensonakamura, @gsushant, @t-works @melloware

Frankly, I was confused when I read the comments. As far as I understand, this problem occurs when you update to v9.0. Can you test this and confirm? Also in v8.7.3 everything works as expected. Right? If we can determine that this issue occurs after a specific version, it will be easier to fix.

primereact: "9.0.0" // not use ^

Best Regards,

@melloware
Copy link
Member

melloware commented Oct 13, 2023

No it started in 9.6.0. If you use 9.5 it works it's in 9.6.0+ when it started.

I somehow think it is PrimeReactContext related from the memory usage.

@mertsincan
Copy link
Member

@melloware ok;) @ensonakamura @gsushant @t-works WDYT? Do you agree with Melloware? v9.5.0 works fine for you. Right?

Thanks a lot!

@mertsincan mertsincan modified the milestones: 10.0.4, 10.0.5 Oct 19, 2023
@habubey habubey modified the milestones: 10.0.6, 10.0.7 Oct 26, 2023
@mertsincan mertsincan modified the milestones: 11.0.0, 10.2.0 Nov 25, 2023
@mertsincan
Copy link
Member

mertsincan commented Nov 25, 2023

Hi,

After long research, I learned that this problem does not exist in 9.5.0, it came with 9.6.0. Later, when I did detailed tests, I realized that the problem was caused by the fix in the #4505
I fixed it now. Can you try this fix after the next version is released? If the problem persists, please feel free to reopen this issue.

Best Regards,

@melloware
Copy link
Member

Nice work!

@cagataycivici
Copy link
Member

Great work my man! Glad to have you back at PrimeReact! 👑

@chiefdeals
Copy link
Contributor

chiefdeals commented Dec 3, 2023

I had this issue after upgrading from 9.2 (to 10.1), so that'd support the 9.6 conclusion. Was having this problem in 10.1 specifically with text filtering of a single key's value.

Don't know if it's just me, I'm getting hit worse now in 10.2.1 with any array over 30 documents, though reduction of array size with text filter appears to perform better. Simplistic objects in these arrays, too. useMemo'd the array, as well as alerted in console when it did change, to ensure was not changing constantly.

Am I the only one feeling like something else is not right? If I can get a confirmation that others are feeling this too, I'll set time aside to investigate

Bummed because I want to use passthrough but I NEED datatable

e: rolling back to 9.2.3 just fixed it /e2 we're on 9.5.0 for now, thanks for identifying that @mertsincan - can confirm it is not impacted by the defect

@melloware
Copy link
Member

@chiefdeals you are saying its not an issue in 9.5.0 but still is in the latest 10.2.1 ?

@chiefdeals
Copy link
Contributor

Yes

@melloware melloware reopened this Dec 3, 2023
@github-actions github-actions bot added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Dec 3, 2023
@melloware
Copy link
Member

In this example that was from the original author I see with 10.2.1 the memory stabilizing and continue to garbage collect?

https://codesandbox.io/p/sandbox/primereact-datatable-memory-issue-forked-wcwgkt?file=%2Fsrc%2Findex.js

@melloware melloware removed the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Dec 3, 2023
@mertsincan
Copy link
Member

Hi @chiefdeals, sorry but I'm a little confused. Do you think datatable with filter is running slow? Or are you having a memory leak problem?

@chiefdeals
Copy link
Contributor

chiefdeals commented Dec 3, 2023 via email

@mertsincan
Copy link
Member

Thanks for the update! We made a lot of releases between 9.5.0 and 10.2.1, and I think we can find the solution more easily if we can find out which version your problem occurs in. Firstly, can you try your case with 9.6.0 and 9.6.4? and can you prepare a test case so we can do some tests? Maybe you can use our showcase demo for the test case.

@melloware
Copy link
Member

melloware commented Dec 4, 2023

@chiefdeals what were your tests based on. I am trying the original issue posted in this ticket and in 10.2.1 there is no memory leak?

@chiefdeals
Copy link
Contributor

I don't know if there is a memory leak, mentioned above that I do not know the root cause. My comments here are in respect to the symptoms experienced. Tests were based on my environment, as a constant, against the different versions of the package that were being discussed; where those deficits were present.

Forgive me, your usage of 'tests' is a bit foreign to me. My background is not as extensive as the other contributors; recently self-taught and have not yet had a collaborative dynamic. I'm happy to assist, where I am able, but that might mean a little more "hand-holding" to get what you need from me. Apologies for that.

@melloware
Copy link
Member

@chiefdeals sorry this ticket was about a memory leak. You responded to this ticket saying you still have a leak with 10.2.1 no?

What we are trying to get to the bottom of its "what is your issue?" Can you create a reproducer similar that shows how to reproduce your issue similar to: https://codesandbox.io/p/sandbox/primereact-datatable-memory-issue-forked-wcwgkt?file=%2Fsrc%2Findex.js

@mertsincan
Copy link
Member

mertsincan commented Dec 4, 2023

Maybe, you can create a new issue for your case. In this way, it will be easier for us to follow the issue. Frankly, I think your problem is not related to memory leak. As Melloware said, a test case in the new issue would be great for us.

Best Regards,

@melloware
Copy link
Member

OK we got to the bottom of it for next release:#5927

@chiefdeals
Copy link
Contributor

chiefdeals commented Feb 21, 2024

Apologies, fell off my radar after we downgraded. I don't have the background that you guys have. Only taught myself to code starting 18-24 mo. ago

@melloware
Copy link
Member

No worries I think we got it but let me know after the next release if your issue is no longer happening.

@chiefdeals
Copy link
Contributor

No worries I think we got it but let me know after the next release if your issue is no longer happening.

I've upgraded to see, from "primereact": "9.2.3" to latest, since I went to upgrade to "primeicons": "7.0.0" anyway. Issue persists, I dont see improvement in a dev environment (did not try build).

My component hardly the same functional component as when I first experienced the issues. It's gone through several iterations and has been rebuilt twice (not tied to this issue - the old version works fine so this is not a blocker)... system based? Dont know... Not having any other weird issues

@melloware
Copy link
Member

Try 10.6.2 please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Performance Issue is performance or optimization related
Projects
None yet
Development

No branches or pull requests

10 participants