AppLovin / AppLovin-MAX-SDK-iOS

84 stars 69 forks source link

Library contains memory leaks: #321

Closed smaksymov closed 2 days ago

smaksymov commented 2 weeks ago

MAX SDK Version

12.4.1

Device/Platform Info

Any

Current Behavior

When you will take a look in memory map after ads integration you will see that library contains memory leaks. Screenshot 2024-04-24 at 03 10 32

Expected Behavior

should be free from memory leaks

How to Reproduce

just use the library and take a look in memory map, check the screenshot.

Additional Info

No response

thomasmso commented 2 weeks ago

@smaksymov - are you destroying the native ad after you are done rendering it? https://dash.applovin.com/documentation/mediation/ios/ad-formats/native-manual#destroy-the-native-ad

smaksymov commented 2 weeks ago

as far as I see destroy is called, as well as reference to loader Screenshot 2024-04-24 at 09 05 07

thomasmso commented 2 weeks ago

Thanks, we'll check it out.

alacau commented 2 weeks ago

Hi @smaksymov, our docs show an example of destroying the previous ad before rendering a new ad. Are you also destroying the ad when you are done with the view controller e.g. in deinit or viewWillDisappear?

smaksymov commented 2 weeks ago

Yes, @alacau as I see in codes previous ad is destroyed before loading next one. But in fact normally "ok" is when objects are released when they loose reference to them ), anyway, previous ad is destroyed as I see in codes.

alacau commented 2 weeks ago

@smaksymov - Could you create a sample project that reproduces the memory leak you are describing? Feel free to share your code snippet through my email alan.cao@applovin.com if you'd like.

smaksymov commented 2 weeks ago

@alacau It's waste of time, easier will be if you will show me this 4 files ALMediationAdapterWrapper, ALDelegateWrapper, ALMediationServiceAdDelegateProxy, ALMediatedNativeAd, will show you memory leak. If you need can sign NDA. My goal is to use memory leak free lib

alacau commented 2 weeks ago

@smaksymov - According to the screenshot you sent above, could it be possible that nativeAdLoader is nil by the time you're calling destroy()? I'd suggest to make sure destroy() is called for each of the loaded ads once you're done with them. This could be when the class is no longer in use (e.g. deinit or viewWillDisappear) or when you're replacing the current loaded ad with a new one.

Unfortunately we cannot disclose our source code. If you're still observing a memory leak, could you reproduce it in our demo app located in this repository? This would be helpful for identifying potential cause for the memory leak.

thomasmso commented 2 days ago

Closing this out as we've not gotten any other reports or response. @smaksymov - feel free to re-open when you have a response for @alacau 's suggestions/questions.