Azure / azure-storage-android

Microsoft Azure Storage Library for Android
Apache License 2.0
81 stars 47 forks source link

upload file OutOfMemoryError #22

Closed aii1991 closed 7 years ago

aii1991 commented 8 years ago

FATAL EXCEPTION: pool-3-thread-1 Process: com.superdata.cxim, PID: 17973 java.lang.OutOfMemoryError at java.io.BufferedInputStream.fillbuf(BufferedInputStream.java:156) at java.io.BufferedInputStream.read(BufferedInputStream.java:288) at com.microsoft.azure.storage.core.Utility.writeToOutputStream(Utility.java:1177) at com.microsoft.azure.storage.core.Utility.writeToOutputStream(Utility.java:1089) at com.microsoft.azure.storage.blob.BlobOutputStream.write(BlobOutputStream.java:645) at com.microsoft.azure.storage.blob.CloudBlockBlob.upload(CloudBlockBlob.java:676) at com.microsoft.azure.storage.blob.CloudBlob.uploadFromFile(CloudBlob.java:1672) at com.microsoft.azure.storage.blob.CloudBlob.uploadFromFile(CloudBlob.java:1644) at com.chaoxiang.imrestful.OkHttpUtils$AzureClient$1.run(OkHttpUtils.java:120) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at java.lang.Thread.run(Thread.java:841)

Test equipment is ximi4. My simple code(phonegap.rar file size is 3GB):

      try {
        CloudStorageAccount account = CloudStorageAccount.parse(storageConnectionString);
        CloudBlobClient blobClient = account.createCloudBlobClient();
        CloudBlobContainer container = blobClient.getContainerReference("cxim");
        container.createIfNotExists();

        BlobContainerPermissions containerPermissions = new BlobContainerPermissions();
        containerPermissions.setPublicAccess(BlobContainerPublicAccessType.CONTAINER);
        container.uploadPermissions(containerPermissions);
        CloudBlockBlob blob1 = container.getBlockBlobReference("phonegap.rar");
        String path = "/storage/emulated/0/BaiduNetdisk/0/Phonegap/phonegap.rar";
        blob1.uploadFromFile(path);

      } catch (Exception e) {
         e.printStackTrace();
      }
emgerner-msft commented 8 years ago

This looks like a duplicate of #12. See that thread for more info on why this happens and how to mitigate.

mirobers commented 7 years ago

Closing this as a duplicate.