We study the problem of capsizing of a rolling ship in harmonic and random beam seas, by means of the Melnikov method and safe basin calculations. In the random excitation case, we consider an integro-differential Cummins-type model equation that takes into account the hydrodynamic memory. The non-linear restoring moment is modeled by a high-order polynomial and the Melnikov criteria are evaluated numerically. We also examine a variant of the classical Melnikov method in which the damping terms are incorporated into the unperturbed system and the perturbation takes a modified form. We compare the theoretical predictions with direct (Monte-Carlo) simulations of the safe basins for two existing ships. In the random excitation case, we quantify the erosion by means of a mean integrity index. For weak damping, the classical and modified Melnikov curves coincide and are in good agreement with the onset of the safe basin erosion. As damping increases the Melnikov curves become less and less conservative with respect to the onset of erosion. Finally, the potential of the Melnikov method to provide a ship classification tool is discussed.