Erasing files from flash memory

So I’m annoyed with the way my utility handles the MemoryStick (MS) from my Sony digital camera, and I decide to write a program that will do a better job. Its duties are to transfer the JPG files to my PC, then erase them from the MS.

After several hours work (hey, I’m new to C#), the thing works pretty well. But I seem to recall that flash memory doesn’t like frequent write and erase cycles: By erasing the files one by one, I may be wearing out my MS.

Is this correct? Is there a good way around the problem - like some method of erasing multiple files in a single operation? How about erasing the folder that contains the files, then re-creating it?

Flash memory is usually good for about 50,000 cycles. I don’t know about you, but I’m not likely to take that many pics during the lifetime of the thing.

I don’t know what they use in memory sticks, but in flash based disk drives they use a system of rotating the bits used for the file system so that you aren’t constantly writing to the same locations. It spreads out the damage, so to speak.

I would suggest looking at the technical data sheets for one of the memory stick makers. I’m sure they have app notes on what they recommend.

c++? COOL. I myself have created various programs if you want any (Linux E-books) just ask.

In XP, I just open the card (its listed as a drive) then I delete files from it. My camera program does have an option to delete files after putting them on the HD. I guess it depends on your computer.

I was doing the file copy and delete manually, but it seemed tedious. My utility program will copy the files to my hard drive, but won’t remove them from the memory stick. I wanted an automatic no-dialog-required approach, so I created one that seems to work.

I’m still wondering if the approach of removing and re-creating the entire directory is any better than the file-at-a-time scheme.

Xema, are you really using XP? When I connect my camera to my PC, I get the Windows Image Acquisition tool (it also appears when I put my CF card in a CF reader). It puts thumbnails on the screen; you can choose to change the orientation (if necessary), then it copies them to a directory you specify. It will even delete them off your CF\MS card if you check the “delete images after copying” box. Is this the “utility” you’re talking about, or is it some crappy Sony software?


Firstly: Its “write cycles”, not “erase cycles” that flash is limited. CompactFlash has, I believe, a million write cycles per block, so you’re pretty safe.

Secondly, flash like CompactFlash (and probably MS) too, abstract all that away. CompactFlash, for example, can run in a couple modes, including “IDE” mode, where the chip looks exactly like a hard disk to the OS.

Wear levelling (where the writes are spread out over the blocks so as to not wear a metaphorical “groove” in the flash) is handled inside the chip.

So, to answer your question, don’t worry about it.