File tree 1 file changed +24
-1
lines changed
1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change 1
- 'use strict' ;
1
+ 'use strict' ;
2
2
3
3
var support = require ( './support' ) ;
4
4
var base64 = require ( './base64' ) ;
@@ -36,6 +36,29 @@ exports.newBlob = function(parts, type) {
36
36
exports . checkSupport ( "blob" ) ;
37
37
38
38
try {
39
+ // Fixed a memory leak occurred in IE11
40
+ // Note:
41
+ // When a large amount of Array is generated in the Blob,
42
+ // the amount of memory nearly 100 times the original data amount is consumed.
43
+ // Change it to create a BLOB only once after join.
44
+ if ( window . MSBlobBuilder ) {
45
+ var concatenation = function ( segments ) {
46
+ var sumLength = 0 ;
47
+ for ( var i = 0 ; i < segments . length ; ++ i ) {
48
+ sumLength += segments [ i ] . byteLength ;
49
+ }
50
+ var whole = new Uint8Array ( sumLength ) ;
51
+ var pos = 0 ;
52
+ for ( var j = 0 ; j < segments . length ; ++ j ) {
53
+ whole . set ( new Uint8Array ( segments [ j ] ) , pos ) ;
54
+ pos += segments [ j ] . byteLength ;
55
+ }
56
+ return whole . buffer ;
57
+ } ;
58
+ // array
59
+ parts = [ concatenation ( parts ) ] ;
60
+ }
61
+
39
62
// Blob constructor
40
63
return new Blob ( parts , {
41
64
type : type
You can’t perform that action at this time.
0 commit comments