Question: I have just purchased a new CF card for my DSLR. I tested it using Xbench (Mac OS X) and it performs as expected. However, I'd like to do a "surface scan" (moving platter term) to check for "bad sectors" (moving platter term). I could bash script a processes using dd, but I get the feeling that there is a better way out there. My goal is to conclusively know that a memory card (CF, SD, etc.) is safe to use on a photo shoot, and that is doesn't need to be returned before the 30 day vendor policy window expires.

I definitely want Mac solutions given here. I would also like to get a few Linux suggestions. Let's even throw a bone to the windows users just so that this one question can meet everyone's needs.

Answer: 
Flash memory does not work the same way as disks with platters. The concept of a "bad sector" does not really exist with flash memory. These days, with flash memory and SSD's, the built-in controller takes care of identifying and marking off unusable blocks of memory, dynamically moving data around to mitigate block write limitations, etc. These features are far more prevalent in SSD's, but some also exist in quality flash cards (such as SanDisk).

Most file system checking tools either make specific assumptions about the physical structure of the storage device (i.e. platter based, with physical cylinders, sectors, clusters, etc.), or work at an abstracted level and make repairs "virtually" using file or directory tables. You would need a tool specifically designed to mark bad blocks on a flash memory device, as anything else is either going to cause more problems (by assuming it can fix the problems the same way it would with a platter-based device) or make virtual fixes that don't take into account dynamic hardware-level features of flash. Even if you could mark a particular "sector" or "cluster" as 'bad', it wouldn't necessarily do any good, since those physical concepts don't actually exist in flash memory. If the flash device is more advanced, and dynamically moves data around to automatically bypass bad blocks and mitigate write limitations, the physical location of data may reside in a bad block one moment, and in a good block a moment later. (Note that the idea of a "bad" block in flash memory is much fuzzier than it is with platter disks...a flash memory block tends to die slowly, rather than suddenly, and may "flicker" between readable/not readable a bit before it becomes entirely unusable.)

Generally speaking, when it comes to flash, let the device manage itself from a bad block perspective. Different manufacturers structure and store data in different ways, and each may have different levels and amounts of dynamic behavior that moves data around to avoid some of the limitations of flash memory. Trying to manage it yourself is likely to cause more problems than it solves, and may render your flash disks useless in the long run.

If you wish to avoid bad flash cards, I highly recommend using reputable brands. I have tried a variety of flash cards in the past, however SanDisk is the only brand that I have used that, at least to date, has never failed. I have several 4, 8, and 16 gig SDHC cards that I use quite heavily, and regularly take out of my camera and insert into my laptop or computer, and they are still working perfectly. (Some are several years old.)
I found this on google, I'm not using sd cards for cameras' storage but instead I got my class 10 32 gigs sdhc sandisk completely corrupted after less then 2 years of use on my samsung galaxy S2.

I am using badblocks to see where the first badblocks start and then I will make partitions around that area if possible. this is my current, very very bad solution :/