-
-
Notifications
You must be signed in to change notification settings - Fork 360
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
Spyk'ed object can't be unmocked which leads to OutOfMemoryError #1013
Comments
I've created pull request https://github.com/mockk/mockk/pull/1018/files |
I found that mock(proxy) objects ,that supposed to be collected by gc, can't be collected despite the fact that weak reference used for storing these objects in WeakMockHandlersMap, because of these proxy objects are strongly reachable via dispose routine |
#1013 uncouple proxy objects from cancellable to make proxy available…
It seems the fix for #997 undid this, as now I'm seeing memory leaks due to spy objects not being GCed once cleared. There must be a way to allow these objects to be GCed when calling @Raibaz do you have any recommendations? Also worth noting that the unit test added in #1018 doesn't actually detect it as it's broken but the tests are passing (I assume). |
Expected Behavior
unmock(spyk()) -- works
No
java.lang.OutOfMemoryError: Java heap space
error occurred.Current Behavior
java.lang.OutOfMemoryError: Java heap space
occursunmock(spyk())
-- does not unmock spyk'ed objectFailure Information (for bugs)
Context
We have a lot of SpringBoot tests .
We annotated
@Lazy
bean with@SpykBean
in our TestCaseBase classAnd sometimes new spring context created and bean get
spyked
again and it leads to OutOfMemoryErrorbecause spiked object can't be unmocked/unspyked
MockK version:
implementation("io.mockk:mockk:1.13.3")
OS:
Darwin 21.6.0 Darwin Kernel Version 21.6.0: Thu Sep 29 20:13:56 PDT 2022; root:xnu-8020.240.7~1/RELEASE_ARM64_T6000 arm64
Kotlin version:
1.7.21
JDK version:
openjdk 11.0.16.1 2022-08-12 OpenJDK Runtime Environment Homebrew (build 11.0.16.1+0) OpenJDK 64-Bit Server VM Homebrew (build 11.0.16.1+0, mixed mode)
Type of test: unit test
Minimal reproducible code (the gist of this issue)
The text was updated successfully, but these errors were encountered: