As far as I can tell, there are four possibilities:
Ubuntu doesn't limit the memory per process by default, but there are ways to set up those limits. The easiest way of knowing what has been done (if anything) would be consulting the person who administrates the server.
If you're on a VPS and not on an actual server, there might be a problem with the configuration of the VM.
I don't know exactly how Java works, but C restricts the memory available to the stack when compiling. In this case, you can either instruct the compiler to increase the stack size or move larger arrays to the heap.
If your OS is 32-bit, the available memory per process is hard-limited (somewhere between 2 GB and 4 GB). If your server has a 64-bit CPU, that can be fixed easily by installing a 64-bit OS.
Possibility 4 is pretty easy to rule out. To verify whether it's 1, 2 or 3, you could compile the following with gcc (or write the equivalent in Java):
#include <stdlib.h>
#include <string.h>
int main(int argc, char **argv)
{
long bytes = atol(argv[1]), counter, *pointer, words = bytes / sizeof(long);
// try to allocate memory
if ((pointer = malloc(bytes)) == NULL)
{
puts("Could not allocate memory");
exit(1);
}
// play with memory, so compiler won't optimize allocation out
for(counter = 0; counter < words; counter++)
pointer[counter] = counter;
exit(0);
}
and execute it the the amount of memory you want to allocate as a command-line option.
You should be able to allocate all memory that's reported as free or cached. If you can,
you rule out possibility 1 and possibly 2.
what version of ubuntu are you running, and what architecture is it... if your messaging application process is 32-bit, it is possible that there is a limit on how much RAM it can use at a time... – user1055604 – 2012-12-30T06:58:15.503