Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
2.6k views
in Java FTP by (160 points)
Our application is uploading files ranging from 2 KB - 15 KB in size and it needs to upload 800,000 - 1,000,000 of them within a single FTP session.

The application gets through about 30,000 of these files then the application gets an java.lang.OutOfMemoryError.

The relevant snippet of code is invoking the FTPClient.put(String localPath, String remotefile, boolean append) method, and possibly calling the mkdir method, if the remote path does not exist.

Given that we are uploading that many files, what is the recommended put method that needs to be invoked? Is there any advantage to using the FTPClient.put(InputStream srcStream, String remoteFile) method?

Thank you

-jeff

2 Answers

0 votes
by (162k points)
An OutOfMemoryError indicates some problem but it is difficult to tell why it is occurring. Make sure you are freeing all your resources. There is no advantage in using the stream methods. You may need some kind of profiler or perhaps print out the available memory at different points in the code to see if you can figure out what is going on.

Perhaps you should be forcing garbage collection periodically if the application has no low cpu periods to allow that to happen?
0 votes
by (160 points)
Thank you, that is good advice in general.

turns out edtftpj wasn't the cause of it at all -- in fact, memory profiler shows that the edtftpj libraries are quite efficient.

Categories

...