• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

HELP! Another Memory Problem

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am creating a web-based application that would be used as a messaging system. Sort of like Yahoo Messenger or Windows Messenger except that it is customized according to the client's requests.

Each user has a console to send/receive/view messages. All the messages received and send by each user would not be directly stored in the DB. Every message received/send would be 1st stored in a sort of message queue memory and after a certain amount of time, would then be purged and stored in the DB. The "memory" used is a singleton class which stores all of the message objects in Lists inside Hashmaps with their keys depending on their classification. The messenger console refreshes every X seconds and retrieves the messages for each user and retrieves this from the singleton which acts as the memory. In retrieving the messages, I decided not to hit from the DB since that would cause performance issues in connecting to the DB even if there is connection pooling. Remember that the page refreshes every X seconds to receive incoming messages in real time and there are approximately 50 users that will be using this.

Now, the problem is...once there are already a number of messages stored in the memory. The console page starts to freeze and after some time, the entire system throws an OutOfMemory exception. Is this caused by the memory class? Can anyone enlighten this novice developer what to do?
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If this was my problem I would start by monitoring memory usage with the various methods in java.lang.Runtime. Perhaps you could log the totalMemory and freeMemory values to see if memory available drops slowly or suddenly.
Are you using the default memory allocation or setting a higher one? (see the tooldocs for the command line memory related parameters)
How many Threads are in operation here? It looks like an opportunity for a separate low priority Thread to do the DB backups while one or more high prioriy Threads handle communication.
Bill
 
My favorite is a chocolate cupcake with white frosting and tiny ad sprinkles.
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!