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

Fatal Memory Leak during compilation #12

Open
s-mayrh opened this issue Jun 5, 2024 · 5 comments
Open

Fatal Memory Leak during compilation #12

s-mayrh opened this issue Jun 5, 2024 · 5 comments

Comments

@s-mayrh
Copy link

s-mayrh commented Jun 5, 2024

When building the project using cargo leptos watch memory and swap (zram) get gradually filled up by rustc while Compiling phosphor-leptos v0.5.0 until the system becomes unresponsive. After watching this for 45 minutes I had to pull the plug and pray for no file system errors because it never stops accessing the drive. I had no memory issues before when building Rust packages on this device.

Hardware: Raspberry Pi 4, 8GiB RAM
OS: Manjaro ARM/aarch64
Filesystem: btrfs

@SorenHolstHansen
Copy link
Owner

Ufff, sounds bad, sorry for that. I have no idea what could be the cause, except for perhaps the huge amount of files, which I can't really do anything about.

If you figure out a fix, I would be happy to accept a PR

@s-mayrh
Copy link
Author

s-mayrh commented Jun 6, 2024

I disabled zram and connected a mechanical drive where I added 16GiB swap.

So far i could build the first stage of Leptos (is it hydration or SSR? I never know) but it took longer than an hour to build. I made these screenshots before I went to bed so I can't say how long it took actually.
Screenshot_20240606_032341
Screenshot_20240606_032428
These screenshots show the system state after one hour of building (and heavy swapping). I have seen that rustc got a memory footprint of 14GiB later, which is 6 more than physical RAM present.

Nevertheless first stage built, but I had a syntax error and needed to build again. At least the first stage did not need to recompile the icon library. In the second stage where the SSR or hydration part is built (I don't know which) I had a similar picture, but after three hours and a rustc footprint of 10GiB the system became unresponsive again while swapping heavily. These photos were made when the UI stopped being refreshed (take a note at the "99,7 wa" on the top:
IMG_20240606_161244
IMG_20240606_161217b

After 4 hours I had to pull the plug as the system showed no activity on the internal, the external swap drive, and my bluetooth devices lost the connection.

I could theoretically try on my Windows computer, but that one has even less (4GiB) RAM and I assume it's a question of RAM not CPU architecture. To mitigate this I think, based on #7, the icon categories could be put in 19 separate sub crates that could still be gated with the feature flags on the main crate to keep compatibility. AFAIK crates are the linking units in Rust and that way the build process could be split into smaller. memory-manageable workloads

@SorenHolstHansen
Copy link
Owner

We already have the feature flags. Have you disabled default features and only included the features you need? that might help

@SorenHolstHansen
Copy link
Owner

Can you check if the issue persists on v0.6.0?

@s-mayrh
Copy link
Author

s-mayrh commented Nov 16, 2024

I will test it next week

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants