Can we allocate 10 gb RAM to postgres out of 30gb
Yes one can allocate the Shared Memory with a Kernel Flag this is documented in Postgresql Documentation

https://www.postgresql.org/docs/current/kernel-resources.html 

Also may want to look into Huge Page same link further down

note this is Shared Memory other settings eat up memory independently,  see the postgres.conf  for more details