SD library run out of the ram

Hi, Thanks for your time. I get a problem with my SD code. I am using mega2560 and SD shield. And I am using the SD library. The program just write and read some txt files which stored on the SD card. It works for only several mins. I checked the memory. It keep reducing until 370. Then I can not operate any file again. I think I have close the file after It was used and I operate only one file everytime. why the memory never be released? Is there something I have missed? please give some help thanks a lot.

Be certain that every file you open is also explicitly closed.

Cheers

Catweazle NZ

Hi thank you
I solved this porblem

I wrote this part code before the file.close, every time It can not release the memory.
so I moved and calculate after file.close.
then It works, It seems like we can not operate too much before we close the file.

end_addressL=0;
end_addressL +=(uint32_t)UID_byte[0]<<24;
end_addressL +=(uint32_t)UID_byte[1]<<16;
end_addressL +=(uint32_t)UID_byte[2]<<8;
end_addressL +=(uint32_t)UID_byte[3];