Arduino with SD Card Memory Leak

I would like listing files on Arduino with SD card.

#include <MemoryFree.h>
#include <SD.h>

String current_directory;
File directory;
File filesystem_member;

void list_files(void)
{
  Serial.print("Directory: ");
  Serial.print(current_directory);

  while (filesystem_member = directory.openNextFile())
  {
    Serial.write('\n');
    Serial.print(filesystem_member.name());

    if (!filesystem_member.isDirectory())
    {
      Serial.write('\t');
      Serial.print(filesystem_member.size());
      Serial.print(F(" byte"));
      Serial.write('\n');
    }

    filesystem_member.close();
  }

  filesystem_member.close();

  directory.rewindDirectory();
}

void setup()
{
  Serial.begin(9600);
  SD.begin();
  list_files();
  Serial.println(freeMemory());
  directory = SD.open("/");
}

void_loop()
{
  list_files();
  Serial.println(freeMemory());
  delay(2000);
}

But, the code has memory leak problem. Free memory are decreasing.

Has Arduino a bug?

Thanks for replies.

Free memory are decreasing.

You've provided no proof of that.

PaulS:
You've provided no proof of that.

The code printing free memory. Printed free memory is decrasing.

Remove "SD.open()" from setup and try this in loop:

directory = SD.open("/");
list_files();
directory.close();
Serial.println(freeMemory());
delay(2000);

Danois90:
Remove "SD.open()" from setup and try this in loop:

directory = SD.open("/");

list_files();
directory.close();
Serial.println(freeMemory());
delay(2000);

No memory leak on this code.

You probably ought to follow all of the advice that you were given in your other thread before you try anything else.

Thanks for replies. I forgot directory.close(); line.