Memory Leak on DARemoteDataAdapter

Dear All,
As below code:

after free the daPub2,
it has memory leak, the Leak qty depends on the how many tables I want to load from server.
how should I write the DAPub2, correctly?

on Instruments shows:

----Root Leak(2)
----1.Malloc 32 Bytes
----2.Malloc 48 Bytes

      daPub2 = DAPub2.init()
        let names = ["pvMasterUsers","pvMasterUserRolls"]
        daPub?.loadDataTables(tableNames: tableName)



-------------


class DAPub2: NSObject,DAAsyncRequestDelegate {
    var adapter:DARemoteDataAdapter?
    var request:DAAsyncRequest?

    override init(){
        adapter = DARemoteDataAdapter.init(targetURL: pa.loginInfo.hostURL!, dataServiceName: pa.loginInfo.Service_Name_Public)
        adapter?.dataService?.message.envelopes?.setValue(ROAESEncryptionEnvelope.init(password: SERVER_PASSWORD), forKey: "AES")
        super.init()
    }
    
    func loadDataTables(tableNames:[String]){
            request = adapter?.beginGetDataTables(tableNames, start: false)
        request?.delegate = self
        request?.start()
        
    }
    
    func asyncRequest(_ request: DAAsyncRequest, didReceiveTables tables: [String : DADataTable]) {
        print(tables)
        request.setValue(nil, forKey: "request")

        
    }
    deinit {
        adapter?.dataService?.message.envelopes?.removeAllObjects()

        request?.delegate = nil
        request?.setValue(nil, forKey: "adapter")
        request = nil
        adapter = nil
    }
}

Jason,

I’m afraid I’ll sewed some more context for this, for example, when do you release Pub2? you realize the call to loadData is async, to it will execute the request in the background, holding on to the data adapter and everything needed, for the time. freeing the DA before the request finishes will probably los not be fun. At the very least, I’ll need a full and complete piece if code, to just a couple shippers without context.

I cannot reproduce any leaks when running a simple DA sample app, such as the one for download from the dataabstract.com home page.

Hi Marc
I was release the Pub2 after all operations is completed,
That I had finished all data operations.

By the way, when I release the Pub2 , without release the DARemoteDataAdapter(I keep it alive on another class ), it has no leak,

On my program it will have many module need to call Pub2.
I have a solutions, that keep single DARemoteDataAdapter on another module.
but….when 2 module need to load data in same time, I don’t know how to use the DARemoteDataAdapterDelegate…
cause I only have one instance of DARemoteDataAdapter , if I create multi instance of DARemoteDatatAdapter, I can’t release it , after release it will have memory leak.

Hm, thats even stranger.

I recommend to not use the delegate methods, but the methods with callback, eg beginGetdataTables... the RDA itself is fully reentrant, so a single instance can handle as many requests at the same time as you need.