shmget failed - cannot allocate memory

Hi,

In my proj, one process was running for 2 days. after 2 days its throwing an error message "shmget failed cannot allocate memory". the same problem happened every time.i.e. i can reproduce the same issue if my process is running for every 2 days for a same operation.Within this 2 days there are 2500 operation were completed. after ~2500 operation this problem occured every time.once it thrown an error from then on(from the next operation) the same error was thrown continuosously.

my process name is Server.

the top command output for my process at the time when the problem occured.

top - 01:14:10 up 6 days, 1:23, 7 users, load average: 0.99, 1.03, 1.12
Tasks: 1 total, 0 running, 1 sleeping, 0 stopped, 0 zombie
Cpu(s): 26.5%us, 1.4%sy, 0.0%ni, 71.9%id, 0.0%wa, 0.2%hi, 0.1%si, 0.0%st
Mem: 4055852k total, 4025864k used, 29988k free, buffers
Swap: 4200444k total, 4200408k used, 36k free, 512380k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
24403 root 20 0 2904m 1.0g 3228 S 0 25.7 162:28.16 Server

RAM size is 4GB.

Is it because of memory leak? or for the 4GB memory it can be supported only 2500 operation?

free command output:
free -m
total used free shared buffers cached
Mem: 3960 3841 119 0 44 921
-/+ buffers/cache: 2874 1086
Swap: 4101 255 3846

Output of the

#cat /proc/sys/kernel/shmmax
18446744073709551615

#cat /proc/sys/kernel/shmmni
4096

#cat /proc/sys/kernel/shmall
1152921504606846720

Regards,
Mani

P.S: the top command output for the same process one day back:

top - 10:20:52 up 5 days, 10:29, 4 users, load average: 1.55, 1.51, 1.49
Tasks: 1 total, 0 running, 1 sleeping, 0 stopped, 0 zombie
Cpu(s): 26.6%us, 1.3%sy, 0.0%ni, 71.6%id, 0.3%wa, 0.1%hi, 0.1%si, 0.0%st
Mem: 4055852k total, 3980588k used, 75264k free, 16448k buffers
Swap: 4200444k total, 3580824k used, 619620k free, 661580k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
24403 root 20 0 2510m 999m 6164 S 0 25.2 140:05.11 Server

yes, you are out of memory - before:
Mem: 4055852k total, 3980588k used, Swap: 4200444k total, 3580824k used, 619620k free
after:
Mem: 4055852k total, 4025864k used, Swap: 4200444k total, 4200408k used, 36k free
I would say yes, you have a memory leak, or somewhere there is a bug in your program and it is allocating too much memory.
(Although you dont seem to have a massive amount of memory available in the "before" "top")