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

isAddress function causes memory leak on iOS 18+ #2911

Open
1 task done
memoyil opened this issue Oct 23, 2024 · 3 comments
Open
1 task done

isAddress function causes memory leak on iOS 18+ #2911

memoyil opened this issue Oct 23, 2024 · 3 comments
Labels
Good First Issue Misc: Good First Issue

Comments

@memoyil
Copy link

memoyil commented Oct 23, 2024

Check existing issues

Viem Version

2.21.22

Current Behavior

The isAddress function in the viem library appears to cause a memory leak on devices running iOS 18 or later. When repeatedly calling isAddress in an iOS environment (version 18+), memory consumption steadily increases and is not released, leading to degraded app performance and eventually crashing after prolonged usage.

Expected Behavior

No response

Steps To Reproduce

Use the isAddress function to validate addresses in a loop (having more items than 8k) or with frequent calls in an iOS app (version 18+).

Platform: iOS 18+
Browser: Any
App: React-NextJs Web app

Link to Minimal Reproducible Example

No response

Anything else?

No response

@tmm tmm added the Good First Issue Misc: Good First Issue label Oct 23, 2024
@1997roylee
Copy link

It's better if you can provide a example.

@memoyil
Copy link
Author

memoyil commented Nov 4, 2024

It's better if you can provide a example.

i will prepare

@wkyleg
Copy link
Contributor

wkyleg commented Nov 15, 2024

@memoyil Does setting the strict parameter to false fix this?

If so, this would suggest that the underlying issue is from storing in the LruMap. Unfortunately, this class extends directly from the native Map() implementation so it would be hard to fix.

Another test would be if the issue comes from verifying the checksum. This could be tested by running a simplified address check against all addresses, for instance just allowing any 40 character string starting with 0x and containing only valid hexadecimal numbers. A simplified version for this test could be:

function isValidEthereumAddress(address: string): boolean { // Check if the address is a valid Ethereum address return /^0x[a-fA-F0-9]{40}$/.test(address); }

If this doesn't cause the memory leak there may be an issue from the checksum

@wevm wevm deleted a comment from Fgg4672vs6sgustw72 Nov 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good First Issue Misc: Good First Issue
Projects
None yet
Development

No branches or pull requests

5 participants
@memoyil @tmm @wkyleg @1997roylee and others