Bug? Memory leak with FileSytem?

kolbe

Active Member
Licensed User
Longtime User
On the ESP32 the following code increases allocated RAM about 500 bytes each iteration until it runs out of RAM. Am I missing something? SKIP_B4RNEW doesn't make a difference. Library version is 1.10.

B4X:
#Region Project Attributes
    #AutoFlushLogs: True
    #CheckArrayBounds: True
    #StackBufferSize: 300
   
'    #DefineExtra: #define B4R_MEMORY_ALIGNMENT 3
    #DefineExtra: #define SKIP_B4RNEW
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'Public variables can be accessed from all modules.
    
    Public Serial1 As Serial

    Private fs As ESP8266FileSystem
    Private timer1 As Timer
End Sub

Private Sub AppStart
    Serial1.Initialize(9600)
    Log("AppStart")
    
    fs.Initialize
    
    timer1.Initialize("fs_loop",1000)
    timer1.Enabled=True
End Sub

Sub fs_loop
    Log(" Stack: ",StackBufferUsage," RAM: ",AvailableRAM)
   
    For Each f As File In fs.ListFiles("/")
        Log("Name: ", f.Name, ", Size: ", f.Size)
    Next
End Sub

logs show

B4X:
 Stack: 0 RAM: 373924
Name: /logs.txt, Size: 5708
 Stack: 0 RAM: 373248
Name: /logs.txt, Size: 5708
 Stack: 0 RAM: 372756
Name: /logs.txt, Size: 5708
 Stack: 0 RAM: 372264
Name: /logs.txt, Size: 5708
 Stack: 0 RAM: 371772
Name: /logs.txt, Size: 5708
 Stack: 0 RAM: 371280
Name: /logs.txt, Size: 5708
 Stack: 0 RAM: 370788
Name: /logs.txt, Size: 5708
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…