Problem With Large (2MB) JPG Download

Bill Norris

Active Member
Licensed User
Longtime User
My app crashes when downloading and saving large jpg file with httputils. By large, I am meaning maybe 2 MB or larger. Is this a B4A issue or android issue, and is there a workaround, or at least a way to trap it ahead of time?
 
Last edited:

Bill Norris

Active Member
Licensed User
Longtime User
RE:

This occurs when I am downloading a list of files. It is occurring in the file.copy2 line of the following code:

B4X:
   Dim out As OutputStream
      out = File.OpenOutput(File.DirDefaultExternal,file_name,False)
      File.Copy2(HttpUtils.GetInputStream(link), out)
      out.Close



All I get in the log is the name of the last file to come over before the crash. If I try downloading one file at a time, I don't seem to have a problem -- only when I am using downloadlist. Perhaps is a memory issue.
 
Upvote 0

Bill Norris

Active Member
Licensed User
Longtime User
RE:

Reviewing the unfiltered log confirms OUTOFMEMORY error, at the point that a 2MB file is being processed at the File.Copy2 line below

B4X:
Dim out As OutputStream
      out = File.OpenOutput(File.DirDefaultExternal & "/images/wine/",file_name,False)
      File.Copy2(HttpUtils.GetInputStream(link), out)
      out.Close

I am downloading about 200 files, and there are a few large files sprinkled throughout. I am wondering if there isn't a way to do, say, 10 at a time, with some kind of break to free up memory before the next block of 10, etc. I can download a single 2MB file by itself with no problem.
 
Upvote 0
Top