datafaker-net / datafaker

Generating fake data for the JVM (Java, Kotlin, Groovy) has never been easier!
https://www.datafaker.net
Apache License 2.0
1.09k stars 151 forks source link

Memory leak for seeded random use case #1269

Closed vitaly-ivanov closed 2 weeks ago

vitaly-ivanov commented 2 weeks ago

Describe the bug The PROVIDERS_MAP cache size increases when using the seeded random functionality with the doWith method.

This issue is similar to https://github.com/datafaker-net/datafaker/issues/883.

To Reproduce Code to reproduce is here: https://github.com/vitaly-ivanov/datafaker-memory-leak/blob/main/app/src/main/kotlin/org/example/App.kt

Expected behavior I think the cache should not be filled while using the doWith block method as it wraps the callable.

Versions:

Additional context Our aim is to generate the same values for the same random seed. The number of values can be very large.

The fix does not work in this case because new instances of the RandomService and Random classes are used.

But even if the random seed is the same, the equals method returns false because java.util.Random' does not override theequals' and `hashCode' methods.

snuyanzin commented 2 weeks ago

the issue is same as https://github.com/datafaker-net/datafaker/issues/1263 and known, even more this behavior was mentioned in comments of https://github.com/datafaker-net/datafaker/issues/1263 so I don't see a reason to have another open issue

vitaly-ivanov commented 2 weeks ago

@snuyanzin I see, the problem is the same. Could you consider renaming #1263 as it's barely searchable as it is.

snuyanzin commented 2 weeks ago

renamed