Android 如何处理Andengine中的平铺纹理区域

Android 如何处理Andengine中的平铺纹理区域,android,memory-leaks,andengine,Android,Memory Leaks,Andengine,我正在开发一个游戏,我在触摸屏上显示不同的精灵。每个场景都有一组(大约10个精灵)可以根据用户的动作显示和删除。当用户导航到下一个场景时,我加载该场景的精灵,并从缓存中删除第一个场景的精灵。我注意到场景更改时出现了一个小内存泄漏,pin指向在1s场景中创建的TiledTextureRegion变量 我尝试了sprite.reset()调用,但没用。我正在从场景中移除精灵。以下是删除精灵代码的方式: private void removeSprite(final AnimatedSprit

我正在开发一个游戏,我在触摸屏上显示不同的精灵。每个场景都有一组(大约10个精灵)可以根据用户的动作显示和删除。当用户导航到下一个场景时,我加载该场景的精灵,并从缓存中删除第一个场景的精灵。我注意到场景更改时出现了一个小内存泄漏,pin指向在1s场景中创建的TiledTextureRegion变量

我尝试了sprite.reset()调用,但没用。我正在从场景中移除精灵。以下是删除精灵代码的方式:

    private void removeSprite(final AnimatedSprite sprite) {
    final PhysicsConnector facePhysicsConnector = this.mPhysicsWorld.getPhysicsConnectorManager().findPhysicsConnectorByShape(sprite);

    this.mPhysicsWorld.unregisterPhysicsConnector(facePhysicsConnector);
    this.mPhysicsWorld.destroyBody(facePhysicsConnector.getBody());

    this.mScene.unregisterTouchArea(sprite);
    this.mScene.detachChild(sprite);

    System.gc();
}
但看起来它没有清除与sprite关联的TileTextureRegion对象。因为,我会在应用程序中有很多不同的场景,我担心内存泄漏会累积起来并导致问题。 如有任何意见或建议,将不胜感激。
谢谢

您不能清除
平铺纹理区域
,但可以使用
BitmapTextureAtlas.unload()清除
BitmapTextureAtlas

例如:

BitmapTextureAtlas Texture1 = new BitmapTextureAtlas(null, 1024, 1024, TextureOptions.BILINEAR_PREMULTIPLYALPHA);
mEngine.getTextureManager().loadTexture(Texture7);
ITextureRegion example = BitmapTextureAtlasTextureRegionFactory.createFromAsset(Texture1, this, "picture.png", 0, 0);
然后,当您需要时:

Texture1.unload();

但您可能不需要清除内存,因为您将再次使用平铺文本区域。您将重新创建TiledTextureRegion,这将降低应用程序的速度。

谢谢……我担心在缓存中存储大量TiledTextureRegion,因为这将占用大量内存。但最终还是按照您的建议,缓存所有TiledTextureRegion。