hello
I am developing a java application, in my application i have to move data with large size from one object to another and i don't know the perfect way to do it so i can save memory and increase the processing speed because performance is very important in my project.
please can you tell me which scenario is better and why:
1-to include the large data in an string object for ex. and then send the reference of the object to the other object.
2-to save the large data in an file and to send the location of the file to the other object so the other object can read the file and process data.
what cost more saving and reading data in/from the file or transmitting the object referencing to the data from place to place.

"move data with large size from one object to another"? Move or just get access to? How large? Objects in the same JVM? Different JVMs on the same machine? Two machines in the same network?

In general trying to optimise code before its working ("premature optimisation") is a waste of time.

"move data with large size from one object to another"? Move or just get access to? How large? Objects in the same JVM? Different JVMs on the same machine? Two machines in the same network?

In general trying to optimise code before its working ("premature optimisation") is a waste of time.

Well I am trying to move large data like large query results (500KB ) and more from one object to another, so that the second object can process it and the objects are in different JVMs but at the same machine, but i think it is better to save all the data in one list object for ex. and send the reference of the data, is sending the reference (object) referencing to the data
like
List l;
l=-----------
o.sendData(l);
is better than writing it in a file and then after that reading it? please help me

Edited 5 Years Ago by misszeze: n/a

You can't send a ref between different JVMs, but why have 2 JVMs?
If they really are different JVMs the your choices include a file or a socket connection. 500KB is a very small amount of data so either way it's all going to be in in-memory buffers.

thanks so much, thats work for me because i want to develop a search system that analyzes a large amount of data,and i am in the designing process i guess open a socket connection is great thanks again.

You can't send a ref between different JVMs

Yes you can (at least for custom classes) using RMI; moving refs between JVMs is the entire premise of the "distributed objects" theme. :-)

Hi sos
Yes, as always what you write is right. RMI allows you to have a local stub object that redirects method calls (and their returns) to a remote object, thus allowing you to treat the local stub as if it were a direct ref to the remote object.
In the context of the OP's request to "move data with a large size from one object to another" in a performance-critical way, I didn't think that RMI would be relevant - but that was a judgement call, so YMMV. J.

In the context of the OP's request to "move data with a large size from one object to another" in a performance-critical way, I didn't think that RMI would be relevant - but that was a judgement call, so YMMV. J.

I just wanted to make sure that the OP doesn't end up misunderstanding your contextual reply:

You can't send a ref between different JVMs [...]
If they really are different JVMs the your choices include a file or a socket connection

and ends up thinking that raw sockets or files are the only way of doing inter-JVM communication.

Fair enough - although I did specifically say "your choices include.." to avoid giving the impression that my list was exhaustive. Enough now? ;-) J

This question has already been answered. Start a new discussion instead.