Most of us are guilty of spending too much time and effort on friendships where we are giving so much. Hopefully we learn from these experiences, usually as we get older.
Don't beat yourself up about it. You've tried to be a good friend and it can be uncomfortable realising you can't help.