- Monitor OutOfMemoryError in the application console/logs to check whether the heap space needs to be increased.
- Check your IDE console for out-of-memory errors. If there are out-of-memory errors, then add VM options to your IDE to increase the Java memory heap.
- Monitor StackOverflowError while running Word2Vec models. Watch out for the following error:
This error can happen because of unwanted temporary files in a project.
- Perform hyperparameter tuning for Word2Vec models. You might need to perform multiple training sessions with different values for the hyperparameters, such as layeSize, windowSize, and so on.
- Derive the memory consumption at the code level. Calculate the memory consumption based on the data types used in the code and how much data is being consumed by them.