Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8221583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:58:32+00:00 2026-06-07T13:58:32+00:00

I am using this Utility public class Util_ImageLoader { public static Bitmap _bmap; Util_ImageLoader(String

  • 0

I am using this Utility

public class Util_ImageLoader {
public static Bitmap _bmap;

Util_ImageLoader(String url) {
    HttpConnection connection = null;
    InputStream inputStream = null;
    EncodedImage bitmap;
    byte[] dataArray = null;

    try {
        connection = (HttpConnection) Connector.open(url + Util_GetInternet.getConnParam(), Connector.READ,
                true);
        inputStream = connection.openInputStream();
        byte[] responseData = new byte[10000];
        int length = 0;
        StringBuffer rawResponse = new StringBuffer();
        while (-1 != (length = inputStream.read(responseData))) {
            rawResponse.append(new String(responseData, 0, length));
        }
        int responseCode = connection.getResponseCode();
        if (responseCode != HttpConnection.HTTP_OK) {
            throw new IOException("HTTP response code: " + responseCode);
        }

        final String result = rawResponse.toString();
        dataArray = result.getBytes();
    } catch (final Exception ex) {
    }

    finally {
        try {
            inputStream.close();
            inputStream = null;
            connection.close();
            connection = null;
        } catch (Exception e) {
        }
    }

    bitmap = EncodedImage
            .createEncodedImage(dataArray, 0, dataArray.length);
    int multH;
    int multW;
    int currHeight = bitmap.getHeight();
    int currWidth = bitmap.getWidth();
    multH = Fixed32.div(Fixed32.toFP(currHeight), Fixed32.toFP(currHeight));// height
    multW = Fixed32.div(Fixed32.toFP(currWidth), Fixed32.toFP(currWidth));// width
    bitmap = bitmap.scaleImage32(multW, multH);

    _bmap = bitmap.getBitmap();
}

public Bitmap getbitmap() {
    return _bmap;
}
}

When I call it in a listfield which contains 10 childs, then the log keeps saying failed to allocate timer 0: no slots left.

This means the memory is being used up and no more memory to allocate again and as a result my main screen cannot start.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T13:58:34+00:00Added an answer on June 7, 2026 at 1:58 pm

    At the same time you have the following objects in memory:

        // A buffer of about 10KB
        byte[] responseData = new byte[10000];
    
        // A string buffer which will grow up to the total response size
        rawResponse.append(new String(responseData, 0, length));
    
        // Another string the same length that string buffer
        final String result = rawResponse.toString();
    
        // Now another buffer the same size of the response.        
        dataArray = result.getBytes();
    

    It total, if you downloaded n ascii chars, you have simultaneously 10KB, plus 2*n bytes in the first unicode string buffer, plus 2*n bytes in the result string, plus n bytes in dataArray. If I’m not wrong, that sums up to 5n + 10k. There’s room for optimization.

    Some improvements would be:

    • Check response code first, and then read the stream if response code is HTTP 200. No need to read if server returned an error.
    • Get rid of strings. No need to convert to string if after that you are converting again to bytes.
    • If images are large, don’t store them in RAM while downloading. Instead, open a FileOutputStream and write to a temporary file as you read from input stream. Then, if temporary images are still large enough to be displayed, downscale them.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote this utility function: public static <T> List<T> pluck(String fieldName, List list) throws
using System; static class Utility<T, TReturn> { public static TReturn Change(T arg) { //
I'm considering using this jquery utility as a possible solution, but I want to
I am using RijndaelManaged to make a simple encryption/decryption utility. This is working fine,
I have a function in a utility class namespace GUI.code { public class Utility
When using DataContractJsonSerializer to serialize a dictionary, like so: [CollectionDataContract] public class Clazz :
I encountered a class during my work that looks like this: public class MyObject
What is wrong with this code: Header: #include <map> using namespace std; template<class T>
My application has a utility class with static methods which are responsible for showing
Assume I have a class like this: public class Foo { public Bar RequiredProperty

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.