Investors have punished big-spending tech giants and software companies while betting on memory chips.