My ubuntu 16gb ram machine getting stuck after starting elasticsearch

machine is not responding,
when i search in google, i have seen some documentation related to this.
-Xms4g
-Xmx4g
If we add this code, it limits the elasticsearch to use 4gb of ram. but it is not working.