BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 08-10-2005, 10:42 AM   #1 (permalink)
abx
New Member
 
Join Date: Aug 2005
Model: 7290
Carrier: VF
Posts: 6
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with large Strings

Please Login to Remove!

Hi @ll,

I got a Problem with large Strings. I store a lot of Strings in a Vector in Persistent Store. From time to time I need to Mail the results, but I always get an OutOfMemory Error :(
Code:
        // data is the vector
        StringBuffer dataStr = new StringBuffer(130000);
        for (Enumeration el=data.elements(); el.hasMoreElements(); ) {
            dataStr.append((String)el.nextElement() + "\n");
        }
        // own function to send mails
        sendMail("user@domain.tld", "subject", dataStr.toString());
Is there any max size of Strings?

thx,
abx
Offline  
Old 08-10-2005, 09:23 PM   #2 (permalink)
Knows Where the Search Button Is
 
Join Date: Aug 2005
Model: 7100t
Posts: 20
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Page 23 of the Developer Guide (vol 1) says to avoid using enumerations as it creates garbage. Maybe dumping the enumeration will help.

Paul
__________________
--------------------------------
Need a gmail invitation? PM me with your e-mail address. Gmail has free pop access, perfect for the BlackBerry!
Offline  
Old 08-13-2005, 03:57 PM   #3 (permalink)
Thumbs Must Hurt
 
Join Date: Aug 2004
Location: Metro NYC
Posts: 175
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I don't know if there is a size limit on StringBuffer().

But, I would strongly argue against sending 130k emails. RIM's recommendation is to limit data transfers to 2k in size.
__________________
-- Aric Rosenbaum
BlackBerry consulting, BlackBerry development
www.arconsultinginc.com
BlackBerry consulting and development (RIM SI Partner)
Offline  
Old 08-16-2005, 04:36 PM   #4 (permalink)
Knows Where the Search Button Is
 
Join Date: Aug 2005
Model: Lots
Carrier: Rogers
Posts: 21
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

The max size for a String or byte array is 64k.

DaHunter
Offline  
Old 08-18-2005, 06:16 AM   #5 (permalink)
abx
New Member
 
Join Date: Aug 2005
Model: 7290
Carrier: VF
Posts: 6
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thx for all answers. I also find the reason in "Memory best practices for the BlackBerry Java Development Environment"
Quote:
Note: Byte arrays cannot be larger than 128 KB on the handheld.
Offline  
Old 08-18-2005, 07:48 AM   #6 (permalink)
New Member
 
Join Date: Aug 2005
Model: 7100
Posts: 7
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Why do you initialize your stringbuffer?
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.