ESP32CAM SW_RESET after including 4 libraries

Hi! For a project, I need to implement in my esp32cam AI Thinker 3 main functionalities:

I wrote the code but if I run it with the 3 functionalities together I get the following ERROR:
rst:0x3 (SW_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1184
load:0x40078000,len:13232
load:0x40080400,len:3028
entry 0x400805e4
ets Jul 29 2019 12:21:46

But if I run only the Camera + Neural Network or Camera + Wifi/AsyncServer it works

The Tensors for the Neural Network are allocated in PSRAM (only use 250KB)
When it’s working with Cam + Neural Net, once I added a simple line like:
WiFi.mode(WIFI_AP);
It will deliver the same error

I guess that it’s related to the memory but I’m not able to find the issue, I will leave some info that I saw trying to find the problem:

RAM: [==== ] 44.4% (used 145616 bytes from 327680 bytes)
Flash: [=== ] 33.3% (used 1047113 bytes from 3145728 bytes)

Configuring flash size…
Flash will be erased from 0x00001000 to 0x00005fff…
Flash will be erased from 0x00008000 to 0x00008fff…
Flash will be erased from 0x0000e000 to 0x0000ffff…
Flash will be erased from 0x00010000 to 0x00111fff…
Compressed 17536 bytes to 12203…
Writing at 0x00001000… (100 %)
Wrote 17536 bytes (12203 compressed) at 0x00001000 in 0.4 seconds (effective 360.9 kbit/s)…
Hash of data verified.
Compressed 3072 bytes to 137…
Writing at 0x00008000… (100 %)
Wrote 3072 bytes (137 compressed) at 0x00008000 in 0.0 seconds (effective 915.6 kbit/s)…
Hash of data verified.
Compressed 8192 bytes to 47…
Writing at 0x0000e000… (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.0 seconds (effective 1841.2 kbit/s)…
Hash of data verified.
Compressed 1052864 bytes to 688530…
Writing at 0x00010000… (2 %)
Writing at 0x0001bc37… (4 %)
Writing at 0x00025f2e… (6 %)
Writing at 0x00030c1b… (9 %)
Writing at 0x00035a67… (11 %)
Writing at 0x00039f55… (13 %)
Writing at 0x0003e4d2… (16 %)
Writing at 0x00043a63… (18 %)
Writing at 0x00049e97… (20 %)
Writing at 0x0004f248… (23 %)
Writing at 0x00054a77… (25 %)
Writing at 0x0005a145… (27 %)
Writing at 0x0005f8f3… (30 %)
Writing at 0x00064e7b… (32 %)
Writing at 0x0006a486… (34 %)
Writing at 0x0006fa06… (37 %)
Writing at 0x00074c9a… (39 %)
Writing at 0x0007a038… (41 %)
Writing at 0x0007f271… (44 %)
Writing at 0x00084810… (46 %)
Writing at 0x00089946… (48 %)
Writing at 0x0008fcf5… (51 %)
Writing at 0x00095c80… (53 %)
Writing at 0x0009b133… (55 %)
Writing at 0x000a04d8… (58 %)
Writing at 0x000a6197… (60 %)
Writing at 0x000ab762… (62 %)
Writing at 0x000b0a18… (65 %)
Writing at 0x000b5e29… (67 %)
Writing at 0x000bb3dc… (69 %)
Writing at 0x000c0a5b… (72 %)
Writing at 0x000c6252… (74 %)
Writing at 0x000cc019… (76 %)
Writing at 0x000d1998… (79 %)
Writing at 0x000d7fb5… (81 %)
Writing at 0x000e24c6… (83 %)
Writing at 0x000e7c51… (86 %)
Writing at 0x000ed178… (88 %)
Writing at 0x000f87a5… (90 %)
Writing at 0x0010041c… (93 %)
Writing at 0x00105d61… (95 %)
Writing at 0x0010b182… (97 %)
Writing at 0x00110ea2… (100 %)
Wrote 1052864 bytes (688530 compressed) at 0x00010000 in 15.6 seconds (effective 540.8 kbit/s)…
Hash of data verified.

My platformio.ino:

[env:esp32cam]
platform = https://github.com/platformio/platform-espressif32.git
board = esp32cam
framework = arduino
monitor_speed = 115200
board_build.partitions = huge_app.csv
build_flags = -DBOARD_HAS_PSRAM
                -mfix-esp32-psram-cache-issue
board_build.f_flash = 40000000L
monitor_rts = 0
monitor_dtr = 0

huge_app partition: https://github.com/espressif/arduino-esp32/blob/master/tools/partitions/huge_app.csv

Program Size with the 3 functionalities:
text data bss dec hex filename
807943 260376 22401 1090720 10a4a0 .pio\build\esp32cam\firmware.elf

Program Size with only Cam + Neural Net.
text data bss dec hex filename
382693 212404 8353 603450 9353a .pio\build\esp32cam\firmware.elf

Please let me know for any extra information you need! At this point, I’m considering not including the Wi-Fi and Server in the project :sweat: