OutOfMemoryError - Help needed
Hi everyone,
i have the following function in which a query is executed several times, the results are stored in a Vector and the Vector then is stored in a class handling data.
publicvoid getAllSNPsPerGene(Gene g, GeneDataStorage store)
{
SNP s;
Vector<SNP> vec =new Vector<SNP>();
String schema;
if(_study.toLowerCase().equals("study1"))
schema ="study1.";
else
schema ="";
int chr = getChromosomeOfGene(g);
int tabs = getNumberOfSubtables(chr);
Statement stmt =null;
try
{
stmt = getStatement();
}
catch(SQLException e)
{
e.printStackTrace();
}
if(stmt ==null)
return;
ResultSet rs;
for(int j=1; j<=tabs; j++)
{
_query ="SELECT a.a_1, a.a_2, a.snp FROM "+schema;
_query +="my_table"+chr;
_query +="_"+_study+"_pt"+j+" a ";
_query +="INNER JOIN schema.map b using(snp) ";
_query +="WHERE not b.snp=null and b.gene='"+g.getId()+"' ";
_query +="and not a.a_1='-' order by b.snp_id";
System.out.println("Query "+_query+" num of tabs "+tabs);
try
{
rs = stmt.executeQuery(_query);
rs.beforeFirst();
while(rs.next())
{
s =new SNP();
s.setId(rs.getString("snp"));
s.setAlleles(rs.getString("a_1")+
rs.getString("a_2"));
vec.add(s);
s =null;
}
}
catch(SQLException e)
{
e.printStackTrace();
}
}
store.setSNPs(vec);
}
Now what i don't get is that it works very well for around 30 tables and then i get the error. After i process the data - usually the above method retrieves the data found in 15 tables, then the data are processed and then i enter this method again - i call the following method to delete the data and to free memory:
publicvoid clearSNPs()
{
SNP s =new SNP();
for(int i=0; i<_snps.size(); i++)
{
s = _snps.get(i);
s =null;
}
_snps.clear();
}
and before i set the Vector i call clear (just to be sure):
publicvoid setSNPs(Vector<SNP> snps){
if(_snps !=null)
_snps.clear();
_snps =null;
this._snps = snps;
}
So, again, the first methode retrieves the data that fit one criterion, the data are processed, deleted and then the methode is called again and so on. Another strange thing: The process dies when executing a query that does not retrieve a lot of data...
Right now i am really at a loss concerning how i could free enough space or better why the memory is not freed...

