Bug #3258

Crash: Out of Memory on Transport doPost

Added by n8fr8 almost 4 years ago. Updated about 3 years ago.

Status:ClosedStart date:04/15/2014
Priority:HighDue date:04/17/2014
Assignee:n8fr8% Done:

0%

Category:-
Target version:InformaCam - APP Public Beta v2
Component:

Description

Version 0.1.41 (41) | org.witness.informacam.app

Stacktrace

org.witness.informacam.transport.Transport;doPost;Transport.java;199
org.witness.informacam.transport.GlobaleaksTransport;init;GlobaleaksTransport.java;86
org.witness.informacam.transport.Transport;onHandleIntent;Transport.java;486

Reason

java.lang.OutOfMemoryError

Link to HockeyApp

Associated revisions

Revision 6c36f3e0
Added by n8fr8 almost 4 years ago

fixes #3258 makes HTTP Post handle large files
also improves notification UI progress feedback
and cleans up error/retry/fail handling

Revision 6c36f3e0
Added by n8fr8 almost 4 years ago

fixes #3258 makes HTTP Post handle large files
also improves notification UI progress feedback
and cleans up error/retry/fail handling

Revision 1545a984
Added by n8fr8 almost 4 years ago

Merge pull request #49 from n8fr8/bug_3258_transport_memory

fixes #3258 makes HTTP Post handle large files

Revision 1545a984
Added by n8fr8 almost 4 years ago

Merge pull request #49 from n8fr8/bug_3258_transport_memory

fixes #3258 makes HTTP Post handle large files

History

#1 Updated by n8fr8 almost 4 years ago

  • Assignee set to harlo

#2 Updated by n8fr8 almost 4 years ago

Oh, i think I found the problem... since you don't call http.connect() until after you have filled up the BufferedOutputStream, it fills up until the OutofMemory error, since it has no network stream to empty itself to...

We should move http.connect() to before we start writing:

http.setDoOutput(true);
http.setRequestMethod("POST");
http.setRequestProperty("Content-Type", fileData.mimeType);
http.setRequestProperty("Content-Disposition", "attachment; filename=\"" + fileData.assetName + "\"");
//http.getOutputStream().write(informaCam.ioService.getBytes(fileData.assetPath, Type.IOCIPHER));
InputStream in = informaCam.ioService.getStream(fileData.assetPath, fileData.storageType);
BufferedOutputStream out = new BufferedOutputStream(http.getOutputStream());
byte[] buffer = new byte[1024];
int len;
while ((len = in.read(buffer)) != -1) {
out.write(buffer, 0, len);
}
out.flush();
in.close();
out.close();
InputStream is = new BufferedInputStream(http.getInputStream());
http.connect();

#3 Updated by n8fr8 almost 4 years ago

  • Due date set to 04/17/2014
  • Assignee changed from harlo to n8fr8
  • Priority changed from Normal to High
  • Target version set to InformaCam - APP Public Beta v2

Seems to be an issue related to BufferOutputStream too... i am working on a fix!

#4 Updated by n8fr8 almost 4 years ago

  • Status changed from New to In Progress

improving HTTP upload code to not use in memory byte arrays, etc.

#5 Updated by n8fr8 almost 4 years ago

  • Status changed from In Progress to Resolved

#6 Updated by n8fr8 almost 4 years ago

Applied in changeset informacore|commit:6c36f3e002eba92ef9c4739944c32e6c1a47b1d1.

#7 Updated by n8fr8 almost 4 years ago

Applied in changeset informacore|commit:1545a9842b066f93cfbc8ed443f6780c77fa81fe.

#8 Updated by n8fr8 almost 4 years ago

Applied in changeset informacam|commit:6c36f3e002eba92ef9c4739944c32e6c1a47b1d1.

#9 Updated by n8fr8 almost 4 years ago

Applied in changeset informacam|commit:1545a9842b066f93cfbc8ed443f6780c77fa81fe.

#10 Updated by n8fr8 about 3 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF