As you know that every process in Linux environment has these segments.
The memory that you are talking about “Heap” comes within a Process Data Segment which consists of uninitialized data, initialized data and heap. So to view/alter the limits of a process, you can use ulimit command.
To Programmatically change the limits you can use getrlimit/setrlimit.
There are two type of limits
The soft limit is the value that the kernel enforces for the corresponding resource. The hard limit acts as a ceiling for the soft limit: an unprivileged process may set only its soft limit to a value in the range from 0 up to the hard limit, and (irreversibly) lower its hard limit.
Ulimit will only change the values for that shell and it’s child processes only. It will not change the values system wide and is not permanent.
To set the values permanantly make changes in /etc/security/limits.conf. as root.