Memory Error in executing certain functions

Hello!
Okay, so i was trying my hands on the movie sentiment analysis assignment. Now, this is typically a large dataset(may be) with 40k rows. so when i run a cleaning function on it using nltk pipelines, it works fine. but as soon as i count vectorizer method to transform it in an array, i get memory error(happens sometimes, not everytime). So, is it some hardware issue?
any help would be appreciated.
fyi: i have 8gb of RAM