skip to Main Content

Javascript – JS GC in closure

hi i have a query and was unable to get exact answer. I have a below closure function function closure() {let innerVal; return function() {innerVal = innerVal+10}} let inst = closure(); inst(); console.log('end'); will innerVal be cleared during GC after…

VIEW QUESTION

Javascript – Would event listeners prevent garbage collecting objects referenced in outer function scopes?

Let's assume I have the following code: (function () { const largeObject = provideSomeLargeObject(); const largeStaticListOfElements = document.querySelectorAll('span'); const someElementThatWillBeRemoved = document.getElementById('i-will-be-removed'); const elms = document.getElementsByClassName('click-me'); for (let i = 0; i < elms.length; ++i) { const anotherLargeObject = provideAnotherLargeObject();…

VIEW QUESTION

Android Studio – Is there a way to avoid memory leak when executing a code that outlive the caller

Hello hope someone can help me. Problem: In code #1. The code inside "onListenerDisconnected" will not finish executing because the coroutine will be cancelled via onDestroy. code #1 @AndroidEntryPoint class NotificationService : NotificationListenerService() { @Inject lateinit var updateIsNotificationServiceActiveUseCase: UpdateIsNotificationServiceActiveUseCase private…

VIEW QUESTION
Back To Top
Search