I have a problem with memory usage on my application. A short introduction to my app:
The application collects data from a number of MySQL servers (we call these dbs external) and puts the data into one single database (MySQL, we call this db local). The collection should be done periodically. These two classes are of intrest:
- Fetcher. Upon creation of this class it sets up a connection to one of the external servers. This connection will be open until the application terminates. Fetcher has a method, fetch(), which executes a query and gets a ResultSet from the database.

Code:
public void fetch() {
		/*
		 * Create a PreparedStatement, for executing SQL statements
		 */
		Statement stmt;
		
		/*
		 * Create a Vector for storing temporary alarms
		 */
		Vector<Alarm> alarms = new Vector();
		
		try {
			
			/*
			 * If not the first fetch, fetch alarms since last fetch.
			 */
			if (sequenceNbr != -1) {
				String query = "select * from tB_To_CS where " +
				"dwSequenceNo > " + sequenceNbr;
				
				stmt = con.createStatement();
				
				/*
				 * Execute the query and put the result in rs
				 */
				ResultSet rs = stmt.executeQuery(query);		
				
				/*
				 * Iterate over all rows in the recived result set
				 */
				while (rs.next()) {
					
					byte[] message = rs.getBytes("lrMessage");
					/*
					 * If the recived row has an alarm message
					 */
					if (isAlarm(message)) {
						/*
						 * Create a new alarm based on the recieved message
						 */
						Alarm a = new Alarm(message);
						
						/*
						 * Add the new alarm to the alarm vector
						 */
						alarms.addElement(a);
					} else {
						System.out.println("Message was not a alarm");
					}
					
					/*
					 * Set new sequenceNbr, in case this is the last row
					 */
					sequenceNbr = rs.getLong("dwSequenceNo");
				}
			} else {
				/*
				 * If this is the first fetch, just fetch max(dwSequenceNo)
				 */
				stmt = con.createStatement();
				
				/*
				 * Execute query
				 */
				ResultSet rs = stmt.executeQuery("select max(dwSequenceNo) " +
						"from tB_To_CS");
				
				/*
				 * Move to the next (the first) line
				 */
				rs.next();
				
				/*
				 * Get the sequenceNbr
				 */
				sequenceNbr = rs.getLong(1);

				System.out.println("Got the last seqNbr: " + sequenceNbr);
			}
		} catch (SQLException e) {
			Logger.getInstance().logEvent(this, "SQLException caught while " +
				"fetching alarms from the CPS database from host " + host + 
				". Exception message: ", e);
		}

		/*
		 * If we recieved any alarms, insert them into the local database
		 */
		if (alarms.size() > 0) {
			//System.out.println("Will now add " + alarms.size() + " alarms.");
			qh.updateAlarms(alarms);
		} 
	}
- FetcherThread extends Thread. Dont think this will need any explanation.
Code:
	public void run() {
		while (true) {
			/*
			 * Perform an alarm fetch from the CPS and insert them into the 
			 * SMT database
			 */
			fetcher.fetch();
			try {
				sleep(SMTDataCollector.ALARM_FETCH_DELAY);
			} catch (InterruptedException e) {
				Logger.getInstance().logEvent(this, "AlarmFetcherTread " +
						"interrupted.", e);
			}
		}
	}
Since Fetcher.fetch only is accessed by one thread (there is one FetcherThread and one Fetcher for each external database) there shouldnt be any special real time requirements here. Everything concerning the local database can be ignored at this point, it has nothing to do with my problem (same **** happens when qh.updateAlarms() is commented).

So to my problem. The code above eats memory like crazy (for one extrenal database, i.e. one Fetcher and one FetcherThread, 1mb each 10 minutes), even if I just execute the query and then ignore the ResultSet.
The result returned from the query are at max 10-15 rows.
I've tried setting everything to null in the end of Fetcher.fetch(), calling alarms.removeAllElements(), replacing Vector with LinkedList and explicitly call System.gc() but with no success.

I did some profiling (with TPTP), and it seems like the GC misses to collect about 50% of the vectors elemets (instances of Alarm). The Alarm class simply is a container, and has no references to other objects. But as I mentioned above, even with this part removed it leaks memory.

btw. the constant SMTDataCollector.ALARM_FETCH_DELAY = 3000, i.e. the thread will sleep for 3 seconds.

Any thoughts about this are very appriciated.