Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Developer
Posts: 137
Registered: ‎12-22-2010
My Device: Curve 8520
My Carrier: Software Developer

Writing a 15 MB file with Web Works and prevent memory leak

Hi,

 

I have a bad issue in my app. If my user try to write a file around 15 MB with blackberry Playbook the apps crash (without message). A little research shows me, that the app pulls up to 500 MB memory while using the stringToBlob function. My idea was to split the call into chunks.

 

var blobs: Blob[] = [];
var pos: number = 0;
var len: number = data.length;                

while (pos < len) {                    
   blobs[blobs.length] = blackberry.utils.stringToBlob(data.substr(pos, CHUNK));
   pos = blobs.length * CHUNK;
}

blackberry.io.file.saveFile(filePath, new Blob(blobs)); // new Blob does not work ... how to concat

I can reduce the memory usage this way ... but I cannot write the file because I don't see a way to concat the blobs again or append blobs to existing file.

 

Any ideas?

Developer
Posts: 152
Registered: ‎12-03-2012
My Device: PP
My Carrier: base(kpn)/BE, t-mobile/PL

Re: Writing a 15 MB file with Web Works and prevent memory leak

1) check if there is a size limit for a string length:

http://developer.blackberry.com/html5/apis/blackberry.utils.html#.stringToBlob

2) maybe this link will help you:

http://www.html5rocks.com/en/tutorials/file/filesystem/#toc-file-appending

--
Regards,
Pawel Gorny
my apps: http://pawelgorny.com/
PGpgp, Your Reply, Anagrammatist, Texas Hold'em Odds Calculator, Contacts to CSV
If your issue has been solved, please resolve it by marking "Accept as Solution"
Developer
Posts: 137
Registered: ‎12-22-2010
My Device: Curve 8520
My Carrier: Software Developer

Re: Writing a 15 MB file with Web Works and prevent memory leak

1) There is no documented limit for playbook. I cannot write smaller chunks becaue there is no FileWriter in PB :smileysad:

 

2) new Blob() does not work on Playbook

BlackBerry Development Advisor
Posts: 841
Registered: ‎07-15-2008
My Device: Passport
My Carrier: Bell

Re: Writing a 15 MB file with Web Works and prevent memory leak

I think you'll have to switch to either the HTML5 file system apis to do smaller writes and seek to the location to write to, or modify your PlayBook WebWorks SDK to add seeking options to the existing file methods. The current ones are just not sophisticated enough to do what you need.

Tim Windsor
Open Source Technical Lead