DJI PSDK leaks memory and resources even when calling de-init
703 0 2023-2-14
Uploading and Loding Picture ...(0/1)
o(^-^)o
djiuser_KtYl0gScr6EJ
lvl.1

Australia
Offline

I have a super simple example:

```
    DjiUser_SetupEnvironment();

    T_DjiUserInfo userInfo{
        "TEST",
        "12345",
        "appId",
        "appId",
        "me@my_email.com",
        "460800"};

    DjiUser_FillInUserInfo(&userInfo);
    DjiCore_Init(&userInfo);
    DjiCore_DeInit();
```

This works, correctly connects to the drone and prints the drone type:

```
[1398845.336][core]-[Info]-[DjiCore_Init:163) Identify AircraftType = Matrice 300 RTK, MountPosition = Payload Port NO3, SdkAdapterType = Skyport V2
Local write: [1398845.336][core]-[Info]-[DjiCore_Init:163) Identify AircraftType = Matrice 300 RTK, MountPosition = Payload Port NO3, SdkAdapterType = Skyport V2
```

However

When we shut down, i have modified the dji application to count the memory allocations and de-allocations as well as thread creation and joining and various other things. It seems that the psdk does not release all of its memory or resources. This is a resource leak a bug. For example, for memory, the psdk misses de-allocating these pointers:

```
===============   Mem Table  ==============
     Pointer    |      size  (bytes)   
0x561260809460    |     336
0x561260804cd0    |     48
0x5612607ffcc0    |     96
0x561260804c50    |     24
0x561260804bf0    |     24
0x7f75b4000d10    |     384
0x7f75b4000b60    |     384
0x561260804af0    |     24
0x5612607ff7a0    |     48
0x7f75ac001090    |     23
0x7f75ac0010d0    |     92
0x7f75ac0013c0    |     152
0x561260804e30    |     4
0x5612608003f0    |     2048
0x7f75ac001270    |     23
0x5612607ff880    |     48
0x561260804bb0    |     24
0x5612607ff7e0    |     48
0x7f75ac0014a0    |     92
0x7f75ac001530    |     152
   TOTAL: 3.97852kb
```

It also misses releasing mutex's, semaphores and threads. This is all just from initialising the core. There may be more when we actually run the application.

I think this must be a bug with the PSDK.
2023-2-14
Use props
Advanced
You need to log in before you can reply Login | Register now

Credit Rules