Coder Social home page Coder Social logo

Comments (29)

GoogleCodeExporter avatar GoogleCodeExporter commented on July 26, 2024
This is the default out of memory error.


Haven't encountered any using osmdroid. Maybe fixed?

Original comment by viesturz on 7 Apr 2010 at 4:55

from osmdroid.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 26, 2024
i will check if i have the last version and if it fixed this problem. 

Original comment by [email protected] on 7 Apr 2010 at 6:52

from osmdroid.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 26, 2024
I do have the same problem with a Nexus One device.
But till now I didn't get an OutOfMemoryException on a G1. Of course I'm using 
the 
latest version of osmdroid.

So this is kind of strange. I'm going to try to fix this when I get back my 
Nexus One.

Original comment by [email protected] on 8 Apr 2010 at 2:24

from osmdroid.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 26, 2024
I found a workaround, which helps but is not the final solution.

1. I exposed a method to clear the entire stack in OpenStreetMapTileCache: 
--------------------------------------------------------------------------
public void clear(){
        mCachedTiles.clear();
    }
2. I changed OpenStreetMapTileProvider to clear the entire cache and call the 
gc:
--------------------------------------------------------------------------------
-

IOpenStreetMapTileProviderCallback mServiceCallback = new
IOpenStreetMapTileProviderCallback.Stub() {

        @Override
        public void mapTileRequestCompleted(int rendererID, int zoomLevel, int tileX, int
tileY, String aTilePath) throws RemoteException {
...
                        } catch (Throwable e) {
                            Log.e(DEBUGTAG, "Error deleting invalid file: " + aTilePath, e);
                        }
                    }
                } catch (OutOfMemoryError e) {
!!!!!                   mTileCache.clear();
!!!!!                   System.gc();
                    Log.e(DEBUGTAG, "OutOfMemoryError putting tile in cache: " + tile,e);
                }
            }
            mDownloadFinishedHandler.sendEmptyMessage(OpenStreetMapTile.MAPTILE_SUCCESS_ID);
            if (DEBUGMODE)
                Log.d(DEBUGTAG, "MapTile request complete: " + tile);
        }
    };

Now it usable on my Nexus One. However, there should be a more precise method of
removing bitmaps.

For me, it seems that on the Nexus, the number of Bitmaps is more restricted. 
Some
people think, it is a bug...


Original comment by [email protected] on 10 Apr 2010 at 5:50

from osmdroid.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 26, 2024
The following changes seem to fix the problem for me:

1. in OpenStreetMapViewConstants reduce the number of tiles to 50 (was 75)
public static final int CACHE_MAPTILECOUNT_DEFAULT = 50;

2. in OpenStreetMapServiceConstants introduce new constant
public static final int FS_CACHE_SIZE=16 * 1024 * 1024; // 16 MB

3. in OpenStreetMapTileProviderService refer the new constant instead of 
computing
here directly

        @Override
    public void onCreate() {
        super.onCreate();
        mFileSystemProvider = new OpenStreetMapTileFilesystemProvider(
                this.getBaseContext(), FS_CACHE_SIZE); 
    }

My quick fix above is not necessary now, however, it does not disturb. Perhaps 
the
caches need to be adjusted more precise depending on the hardware or need to be 
made
configurable. I have lots of MB available on my disk, however, 2.1 seems to be
ungenerous on the number of Bitmaps for an app.


Original comment by [email protected] on 11 Apr 2010 at 9:13

from osmdroid.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 26, 2024
Playing with the constants I increased the number of parallel threads to 8 and 
the
disc cache to 64MB shows a drastic (i.e. Google Maps like) improvement of 
usability.

It would be nice, if the app would be configurable or could detect if it could 
run in
lean or fat mode in terms of memory and disc usage.

It is really fun now! Will watch the memory and energy consumption...

Original comment by [email protected] on 11 Apr 2010 at 10:29

from osmdroid.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 26, 2024
Issue 33 has been merged into this issue.

Original comment by neilboyd on 13 Apr 2010 at 1:05

from osmdroid.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 26, 2024
I added the constant as suggested in comment 5, but didn't change the value.

Original comment by neilboyd on 13 Apr 2010 at 7:01

from osmdroid.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 26, 2024
the problem still remains...

Original comment by [email protected] on 13 Apr 2010 at 10:01

from osmdroid.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 26, 2024
Revision 131 uses the suggested values.

Original comment by neilboyd on 15 Apr 2010 at 7:11

  • Changed state: Accepted

from osmdroid.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 26, 2024
Reprodced the error on latest version #133 .
Android emulator 2.1.

Just browsed around for about 1 min.

Original comment by viesturz on 15 Apr 2010 at 9:55

from osmdroid.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 26, 2024
Also added the clear as suggested in comment 4 in revision r134

Original comment by neilboyd on 15 Apr 2010 at 8:10

from osmdroid.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 26, 2024
i have tried the clear and it is a bad solutions because the tiles are shown 
and then disappear when "clear" is 
called. This happens all the time and there is not posible to fix it

Original comment by [email protected] on 15 Apr 2010 at 10:30

from osmdroid.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 26, 2024
Definetely clear is to aggressive because it removes everything.

I am testing a better version and hopefully can post something at the weekend.

Original comment by [email protected] on 16 Apr 2010 at 8:30

from osmdroid.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 26, 2024
The attached code of OpenStreetMapTileCache mitigated the problem. Now it runs 
stable
for a while, however, then there are ConcurrentModificationExceptions later on. 
Hard
to reproduce...

I also run into a NullPointerException later on in 
OpenStreetMapAsyncTileProvider.
Catching like

private OpenStreetMapTile nextTile() {
            while(true) {
                if (mIterator == null) {
                    mIterator = mPending.keySet().iterator();
                }
                if (!mIterator.hasNext()) {
                    return null;
                }
                try {
                    synchronized (mPending) {
                        final OpenStreetMapTile tile = mIterator.next();
                        try {
                            mIterator.remove();
                        } catch(ConcurrentModificationException e) {
                            // couldn't remove this request
                            // never mind, we'll process it again
                        }
                        catch(NoSuchElementException e) {
                            // we shouldn't get this, but just in case
                            return null;
                        }
                        catch(NullPointerException e){
                            // TODO clean this exceptions
                        }
                        return tile;
                    }
                } catch(ConcurrentModificationException e) {
                    // get a new iterator and try again
                    mIterator = null;
                }
            }
        }

rose another ConcurrentModificationException later. The synchronization in the 
code
seems to be incomplete, and catching these Exceptions is no solution. We have 
sync
all the stuff carefully

This is no problem for me, except time. However, I would like to fix this in 
another
branch because I need to touch a lot of classes...


Original comment by [email protected] on 18 Apr 2010 at 9:13

Attachments:

from osmdroid.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 26, 2024
You can see the discussion about synchronization in issue 35.

In my opinion it's not worth the overhead of extra synchronization. As it is 
now it 
occassionally catches a ConcurrentModificationException and returns the "wrong" 
item. 
To me that seems like a reasonable compromise.


Original comment by neilboyd on 18 Apr 2010 at 6:19

from osmdroid.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 26, 2024
My opinion is that this is not a tight loop (executes max some 10 times a 
second and
most of the time is not executing at all) and the overhead of extra sync is far 
lower
than all the fuss of making it work without one.

Original comment by viesturz on 19 Apr 2010 at 7:26

from osmdroid.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 26, 2024
Patch for the following issues:

I attached a working (Nexus One tested) patch to address the following issues:

1. Useful constants
2. Careful sync without any ConcurrentModificationExceptions
@neilboyd:
I think, catching the exceptions is good in normal java environments, however, 
on the 
android you could loose a Bitmap, and not recycling the internal memory creates 
a 
memory leak which hurts later.


3. Download from several servers in parallel, generally possible for all,
implemented for the CYCLEMAP

    CYCLEMAP(R.string.cyclemap, ".png", 0, 17, 8, CodeScheme.X_Y,
            "http://a.andy.sandbox.cloudmade.com/tiles/cycle/",
            "http://b.andy.sandbox.cloudmade.com/tiles/cycle/",
            "http://c.andy.sandbox.cloudmade.com/tiles/cycle/"),

You can use the OpenStreetMapRendererInfo with several servers now, and the 
implementation picks randomly one of the servers. This seems to improve the 
download 
speed enormously. Checking the URLs in parallel with a Firefox sometimes shows 
a 404 
on some tiles, indicating a server problem which is harmless, if you can try 
lots of 
servers.

Room for improvement, choose the servers according to their response time... 

The cyclemap now feels better than the Google maps!

4. Another issue I could not solve: if you turn the display from horizontal to 
vertical or vice versa, the cache seems unnecessarily to fetch everything again.

Is anyone solving this issue?

Have fun,
Thomas

Original comment by [email protected] on 2 May 2010 at 10:00

Attachments:

from osmdroid.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 26, 2024
Hi Thomas

1. Committed in revision 150.
2. I'm still not convinced about synchronization. See also issue 35. That 
doesn't 
mean I disagree, just that I'm standing on the fence.
3. Copied to issue 48.
4. Please make a new issue for this, with more information.

Regards

Neil

PS. Your patch includes the upgrade to API 7 and the 
MultiTouchOpenStreetMapView 
attached to issue 25. I don't think that was intended, and it's not necessary 
following the fix I made for issue 25.

Original comment by neilboyd on 3 May 2010 at 7:54

from osmdroid.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 26, 2024
Regarding not recycling the bitmaps, the docs says that recycle should be 
unnecessary 
and it will happen by itself. Doing it explicitly just makes it happen a bit 
sooner.

Original comment by neilboyd on 3 May 2010 at 8:35

from osmdroid.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 26, 2024
Hi Neil,

@comment 19 I had to send the patches, because my codebase became to different.
Unfortunately, you discovered my guerilla attempt do commit the
MultiTouchOpenStreetMapView :-) 
If nobody else is working on it, I will try to do a reflection patch testing on 
the
existence of the right api next time.

@comment 22
This is true, however, the time until the next garbage collector cleanup is 
performed
might be to long because the native memory comes from another pool, as I 
understood
the case.


Original comment by [email protected] on 3 May 2010 at 12:53

from osmdroid.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 26, 2024
The reflection version is already committed in revision 143 / issue 25.

Original comment by neilboyd on 3 May 2010 at 3:24

from osmdroid.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 26, 2024
anyone can tell me what is the last patch to solve this issue? Because i can't 
solve this problem yet

Original comment by [email protected] on 5 May 2010 at 4:47

from osmdroid.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 26, 2024
Is anybody looking into the rotation issue mentioned in comment 18, point 4 ?
I'm using the OpenStreetMapView in my app, but I'm still having memory issues.
I can reproduce the OutOfMemory error very easily by rotating my screen about 
10 times.

It seems after a screen rotation all the tiles are reloaded into memory, but the
garbage collector hasn't freed the memory from the old tiles yet, which 
eventually
leads to an OutOfMemory error.

Original comment by [email protected] on 27 May 2010 at 8:20

from osmdroid.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 26, 2024
I'm not looking at it, but I made issue 54 for it.

Original comment by neilboyd on 27 May 2010 at 8:52

from osmdroid.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 26, 2024
See also issue 73

Original comment by neilboyd on 21 Jul 2010 at 8:29

from osmdroid.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 26, 2024

Original comment by neilboyd on 10 Sep 2010 at 2:33

  • Changed state: Fixed

from osmdroid.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 26, 2024
[deleted comment]

from osmdroid.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 26, 2024
Im fetching the images url and tring to display it in listview but its giving 
me the following error. If a get 1 or 2 images its giving me the result but the 
following occurs when i get more images. Can u plz help me im not getting it 
since 1 week.
Thanks in advance!

01-02 13:50:16.183: E/AndroidRuntime(1942): FATAL EXCEPTION: pool-1-thread-2
01-02 13:50:16.183: E/AndroidRuntime(1942): java.lang.OutOfMemoryError: bitmap 
size exceeds VM budget
01-02 13:50:16.183: E/AndroidRuntime(1942):     at 
android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
01-02 13:50:16.183: E/AndroidRuntime(1942):     at 
android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:470)
01-02 13:50:16.183: E/AndroidRuntime(1942):     at 
android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:525)
01-02 13:50:16.183: E/AndroidRuntime(1942):     at 
com.loopj.android.image.WebImage.getBitmapFromUrl(Unknown Source)
01-02 13:50:16.183: E/AndroidRuntime(1942):     at 
com.loopj.android.image.WebImage.getBitmap(Unknown Source)
01-02 13:50:16.183: E/AndroidRuntime(1942):     at 
com.loopj.android.image.SmartImageTask.run(Unknown Source)
01-02 13:50:16.183: E/AndroidRuntime(1942):     at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
01-02 13:50:16.183: E/AndroidRuntime(1942):     at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
01-02 13:50:16.183: E/AndroidRuntime(1942):     at 
java.lang.Thread.run(Thread.java:1019)

Original comment by [email protected] on 2 Jan 2013 at 8:22

from osmdroid.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.