G*****9 发帖数: 3225 | 1 在为公司把一个老C++代码转化成为Java。
有一个操作大约是如下的:
int n = 500;
double[][][] V = new double[n][][];
for(int t = 0; t < n; ++t)
{
V[t] = new double[n][];
for(int i = 0; i < n; ++i)V[t][i] = new double[n];
}
结果Eclipse报错说内存不够了。这大约需要1G的内存而已。
是不是Eclipse会给内存设定上界?怎么在Eclipse中调整内存上限? |
d****i 发帖数: 4809 | 2 If you have this kind of code, you should never think about converting this
code from C++ to Java because Java is notoriously slow and bad for
multidimensional array and numerical computation like this. So your group's
decision must be wrong.
【在 G*****9 的大作中提到】 : 在为公司把一个老C++代码转化成为Java。 : 有一个操作大约是如下的: : int n = 500; : double[][][] V = new double[n][][]; : : for(int t = 0; t < n; ++t) : { : V[t] = new double[n][]; : for(int i = 0; i < n; ++i)V[t][i] = new double[n]; : }
|
G*****9 发帖数: 3225 | 3 Yes. I bet so.
In fact, I tell the group that we should leave this type of things to C++
and use Java to drive C++ written SO files. However, I turn out to be the
few knowing C++ in the group, while the rest would only learn Java.
this
s
【在 d****i 的大作中提到】 : If you have this kind of code, you should never think about converting this : code from C++ to Java because Java is notoriously slow and bad for : multidimensional array and numerical computation like this. So your group's : decision must be wrong.
|
d****i 发帖数: 4809 | 4 Then you should leave it as a C++ lib and give the so file to the Java folks
to call it via JNI or JNA. Pretty easy and straightforward.
【在 G*****9 的大作中提到】 : Yes. I bet so. : In fact, I tell the group that we should leave this type of things to C++ : and use Java to drive C++ written SO files. However, I turn out to be the : few knowing C++ in the group, while the rest would only learn Java. : : this : s
|
g*****g 发帖数: 34805 | 5 https://wiki.eclipse.org/FAQ_How_do_I_increase_the_heap_size_available_to_
Eclipse%3F
【在 G*****9 的大作中提到】 : 在为公司把一个老C++代码转化成为Java。 : 有一个操作大约是如下的: : int n = 500; : double[][][] V = new double[n][][]; : : for(int t = 0; t < n; ++t) : { : V[t] = new double[n][]; : for(int i = 0; i < n; ++i)V[t][i] = new double[n]; : }
|
G*****9 发帖数: 3225 | 6 That is exactly what I am thinking. The team lead is green in coding and
fears C++.
folks
【在 d****i 的大作中提到】 : Then you should leave it as a C++ lib and give the so file to the Java folks : to call it via JNI or JNA. Pretty easy and straightforward.
|
g*****g 发帖数: 34805 | 7 It's OK to use JNI, if the performance is critical to the system and Java is
not fast enough. In reality, only select domain is like that. In any case,
it should not be hard to do a prototype and compare performance before you
decide which direction is the right one. The Java is slow argument is often
premature.
【在 G*****9 的大作中提到】 : That is exactly what I am thinking. The team lead is green in coding and : fears C++. : : folks
|
G*****9 发帖数: 3225 | 8 Thank you! I understand your point.
Java's efficiency has been greatly improved, while C++ is enhanced for the
ease-of-use. But each is still the best in their own domain. In my minds, I
still prefer to leveraging the best piece of the two languages.
is
,
often
【在 g*****g 的大作中提到】 : It's OK to use JNI, if the performance is critical to the system and Java is : not fast enough. In reality, only select domain is like that. In any case, : it should not be hard to do a prototype and compare performance before you : decide which direction is the right one. The Java is slow argument is often : premature.
|