H
homecurr
Here is my code.
The String take about 20000 * 30 * 8 = 5M. But once I put them in the
Vector, it takes about 100M memory. Why? How can I fix it? Another
good data structure than Vector?
Thanks,
qq
public static void main(String[] args) {
Vector data = new VTest().load();
int i = 1;
}
public Vector load(){
int row = 20000;
int col = 30;
Vector data = new Vector(100, 100);
for (int i = 0; i < row; i++){
String[] line = new String[col];
for (int j = 0; j < col; j++){
line[j] = " " + (int)(Math.random() * 100000000);
}
data.add(line);
}
return data;
}
The String take about 20000 * 30 * 8 = 5M. But once I put them in the
Vector, it takes about 100M memory. Why? How can I fix it? Another
good data structure than Vector?
Thanks,
public static void main(String[] args) {
Vector data = new VTest().load();
int i = 1;
}
public Vector load(){
int row = 20000;
int col = 30;
Vector data = new Vector(100, 100);
for (int i = 0; i < row; i++){
String[] line = new String[col];
for (int j = 0; j < col; j++){
line[j] = " " + (int)(Math.random() * 100000000);
}
data.add(line);
}
return data;
}