wallet-core icon indicating copy to clipboard operation
wallet-core copied to clipboard

[KMP] Memory leak found in Base58.decode in iOS

Open 10gic opened this issue 1 year ago • 0 comments

Describe the bug

There is a memory leak in file kotlin/wallet-core-kotlin/src/iosMain/generated/com/trustwallet/core/Base58.kt (the iOS generated code for Base58.decode):

package com.trustwallet.core

actual object Base58 {

    // ......

    actual fun decode(string: String): ByteArray? =
        TWBase58Decode(string.toTwString()).readTwBytes()         // toTwString and readTwBytes leak memory!


    // ......
}

Expected behavior The memory needs to be released.

Screenshots Run Base58.decode 100000 times, it takes up to 200 MB of memory: Xnip2024-09-18_15-25-56

Additional context This issue is common and not specific to Base58.decode.

10gic avatar Sep 18 '24 07:09 10gic