unload and replace a texture

Started by raft, January 17, 2011, 04:21:45 AM

Previous topic - Next topic

raft

-in terms of memory usage- what's the best way of replacing a texture?

i sometimes got an OutOfMemoryError after replacing skybox textures, typically at prewarm stage. if i do removeAndUnload first instead of replacing i end up with white empty textures. i may be doing something wrong with removeAndUnload thing.

EgonOlsen

unload() doesn't really unloads but schedules for unloading, which happens in the next render. This is a relic from desktop jPCT...it might not be needed for jPCT-AE in most cases. I'll try to add an option for immediate unloading this evening and see if that helps to fight the memory problem.

EgonOlsen

I've uploaded a new jar here: http://www.jpct.net/jpct-ae/download/tmp/test/jpct_ae.jar

It adds a setting to Config called unloadImmediately. If set to true, unloads will be performed right on calling one of the unload-methods. If this works fine, i'll make it default and remove the setting. Please let me know.

raft

unfortunately i got white textures again..

this is the log in between, in case you wanna see:
V/Jumpy3D (24419): changing background to: rock
I/jPCT-AE (24419): Memory usage before compacting: 7630 KB used out of 15559 KB
D/dalvikvm(24419): GC freed 2790 objects / 1444392 bytes in 66ms
D/dalvikvm(24419): GC freed 738 objects / 58584 bytes in 75ms
I/jPCT-AE (24419): Memory usage after compacting: 6223 KB used out of 15559 KB
I/jPCT-AE (24419): Memory usage after compacting: 6356 KB used out of 15559 KB
I/jPCT-AE (24419): Loading Texture...
D/dalvikvm(24419): GC freed 1379 objects / 101552 bytes in 59ms
I/jPCT-AE (24419): Compressed 1048576 bytes to 172106 bytes!
I/jPCT-AE (24419): Loading Texture...
D/dalvikvm(24419): GC freed 134 objects / 2398680 bytes in 59ms
D/dalvikvm(24419): GC freed 7 objects / 232 bytes in 64ms
I/jPCT-AE (24419): Compressed 1048576 bytes to 181335 bytes!
I/jPCT-AE (24419): Loading Texture...
D/dalvikvm(24419): GC freed 106 objects / 2364760 bytes in 52ms
D/dalvikvm(24419): GC freed 7 objects / 224 bytes in 52ms
D/dalvikvm(24419): GC freed 10 objects / 33096 bytes in 77ms
D/dalvikvm(23540): GC freed 3300 objects / 188384 bytes in 1340ms
I/jPCT-AE (24419): Compressed 1048576 bytes to 183437 bytes!
I/jPCT-AE (24419): Loading Texture...
D/dalvikvm(24419): GC freed 122 objects / 2398392 bytes in 57ms
D/dalvikvm(24419): GC freed 7 objects / 224 bytes in 53ms
I/jPCT-AE (24419): Compressed 1048576 bytes to 200990 bytes!
I/jPCT-AE (24419): Loading Texture...
D/dalvikvm(24419): GC freed 115 objects / 2397904 bytes in 53ms
D/dalvikvm(24419): GC freed 7 objects / 224 bytes in 52ms
I/jPCT-AE (24419): Compressed 1048576 bytes to 246627 bytes!
I/jPCT-AE (24419): Loading Texture...
D/dalvikvm(24419): GC freed 114 objects / 2397840 bytes in 51ms
D/dalvikvm(24419): GC freed 7 objects / 224 bytes in 53ms
I/jPCT-AE (24419): Compressed 1048576 bytes to 130872 bytes!
I/jPCT-AE (24419): Memory usage before compacting: 9690 KB used out of 15559 KB
D/dalvikvm(24419): GC freed 48 objects / 2362048 bytes in 57ms
D/dalvikvm(24419): GC freed 7 objects / 224 bytes in 52ms
I/jPCT-AE (24419): Memory usage after compacting: 7384 KB used out of 15559 KB
D/dalvikvm(24419): GC freed 14 objects / 344984 bytes in 57ms
I/jPCT-AE (24419): Uncompressed 172106 bytes to 1048576 bytes in 131ms!
D/dalvikvm(24419): GC freed 13 objects / 689072 bytes in 55ms
D/dalvikvm(24419): GC freed 4 objects / 240 bytes in 56ms
D/dalvikvm(24419): GC freed 9 objects / 2428128 bytes in 58ms
D/dalvikvm(24419): GC freed 16 objects / 2097656 bytes in 55ms
D/dalvikvm(24419): GC freed 3 objects / 362744 bytes in 52ms
I/jPCT-AE (24419): Uncompressed 181335 bytes to 1048576 bytes in 159ms!
D/dalvikvm(24419): GC freed 13 objects / 727112 bytes in 53ms
D/dalvikvm(24419): GC freed 4 objects / 240 bytes in 57ms
D/dalvikvm(24419): GC freed 15 objects / 2503384 bytes in 59ms
D/dalvikvm(24419): GC freed 10 objects / 2097480 bytes in 53ms
D/dalvikvm(24419): GC freed 3 objects / 366944 bytes in 55ms
I/jPCT-AE (24419): Uncompressed 183437 bytes to 1048576 bytes in 160ms!
D/dalvikvm(24419): GC freed 13 objects / 735776 bytes in 55ms
D/dalvikvm(24419): GC freed 4 objects / 240 bytes in 56ms
D/dalvikvm(24419): GC freed 15 objects / 2521008 bytes in 54ms
I/wpa_supplicant(16599): CTRL-EVENT-SCAN-RESULTS  Ready
D/dalvikvm(24419): GC freed 10 objects / 2097480 bytes in 80ms
D/dalvikvm(24419): GC freed 3 objects / 402048 bytes in 55ms
I/jPCT-AE (24419): Uncompressed 200990 bytes to 1048576 bytes in 209ms!
D/dalvikvm(24419): GC freed 30 objects / 807016 bytes in 69ms
D/dalvikvm(24419): GC freed 4 objects / 240 bytes in 54ms
D/dalvikvm(24419): GC freed 14 objects / 2661304 bytes in 53ms
D/dalvikvm(24419): GC freed 617 objects / 2140576 bytes in 54ms
D/dalvikvm(24419): GC freed 3 objects / 493328 bytes in 53ms
I/jPCT-AE (24419): Uncompressed 246627 bytes to 1048576 bytes in 204ms!
D/dalvikvm(24419): GC freed 13 objects / 988360 bytes in 58ms
D/dalvikvm(24419): GC freed 4 objects / 240 bytes in 54ms
D/dalvikvm(24419): GC freed 39 objects / 3026592 bytes in 96ms
D/dalvikvm(24419): GC freed 660 objects / 2406704 bytes in 52ms
I/jPCT-AE (24419): Uncompressed 130872 bytes to 1048576 bytes in 99ms!
D/dalvikvm(24419): GC freed 13 objects / 524728 bytes in 53ms
D/dalvikvm(24419): GC freed 4 objects / 240 bytes in 54ms
D/dalvikvm(24419): GC freed 39 objects / 2099680 bytes in 93ms
I/jPCT-AE (24419): Pre-warming done!
I/Jumpy3D (24419): changed background to: rock

EgonOlsen

 ??? Are you sure that you have set that Config-setting to true? It's false by default. Please re-download the jar. I've renamed the Config.timingOutput to Config.debugOutput and if true, it will print out some message when unloading the texture.

raft

timingOutput was disabled. still white textures. i set Config.unloadImmediately to true in renderer constructor. unless it's set to false elsewhere in your code (for example when buffer is created) it's set to true.

here are the logs:
V/Jumpy3D (24578): changing background to: rock
I/System.out(24578): unloading skybox
D/dalvikvm(24578): GC freed 162 objects / 5456 bytes in 77ms
I/jPCT-AE (24578): Unloaded texture: 38
I/jPCT-AE (24578): Unloaded texture: 39
I/jPCT-AE (24578): Unloaded texture: 40
I/jPCT-AE (24578): Unloaded texture: 41
I/jPCT-AE (24578): Unloaded texture: 42
I/jPCT-AE (24578): Unloaded texture: 43
I/jPCT-AE (24578): Memory usage before compacting: 7867 KB used out of 13383 KB
D/dalvikvm(24578): GC freed 116 objects / 1230728 bytes in 66ms
D/dalvikvm(24578): GC freed 4 objects / 248 bytes in 56ms
I/jPCT-AE (24578): Memory usage after compacting: 6666 KB used out of 13383 KB
I/jPCT-AE (24578): Memory usage after compacting: 6666 KB used out of 13383 KB
I/jPCT-AE (24578): Loading Texture...
D/dalvikvm(24578): GC freed 95 objects / 37368 bytes in 54ms
I/jPCT-AE (24578): Compressed 1048576 bytes to 172106 bytes!
I/jPCT-AE (24578): Loading Texture...
D/dalvikvm(24578): GC freed 128 objects / 2398480 bytes in 54ms
D/dalvikvm(24578): GC freed 7 objects / 224 bytes in 54ms
I/jPCT-AE (24578): Compressed 1048576 bytes to 181335 bytes!
I/jPCT-AE (24578): Loading Texture...
D/dalvikvm(24578): GC freed 106 objects / 2364760 bytes in 54ms
D/dalvikvm(24578): GC freed 7 objects / 224 bytes in 60ms
D/dalvikvm(24578): GC freed 10 objects / 33096 bytes in 53ms
D/dalvikvm(23549): GC freed 265 objects / 11600 bytes in 525ms
I/jPCT-AE (24578): Compressed 1048576 bytes to 183437 bytes!
I/jPCT-AE (24578): Loading Texture...
D/dalvikvm(24578): GC freed 117 objects / 2398552 bytes in 56ms
D/dalvikvm(24578): GC freed 7 objects / 224 bytes in 54ms
I/jPCT-AE (24578): Compressed 1048576 bytes to 200990 bytes!
I/jPCT-AE (24578): Loading Texture...
D/dalvikvm(24578): GC freed 115 objects / 2397896 bytes in 56ms
D/dalvikvm(24578): GC freed 7 objects / 224 bytes in 56ms
I/jPCT-AE (24578): Compressed 1048576 bytes to 246627 bytes!
I/jPCT-AE (24578): Loading Texture...
D/dalvikvm(24578): GC freed 114 objects / 2397840 bytes in 54ms
D/dalvikvm(24578): GC freed 7 objects / 224 bytes in 57ms
I/jPCT-AE (24578): Compressed 1048576 bytes to 130872 bytes!
I/jPCT-AE (24578): Memory usage before compacting: 10063 KB used out of 13383 KB
D/dalvikvm(24578): GC freed 48 objects / 2362040 bytes in 57ms
D/dalvikvm(24578): GC freed 7 objects / 224 bytes in 55ms
I/wpa_supplicant(16599): CTRL-EVENT-SCAN-RESULTS  Ready
I/jPCT-AE (24578): Memory usage after compacting: 7757 KB used out of 13383 KB
D/dalvikvm(24578): GC freed 14 objects / 344984 bytes in 54ms
I/jPCT-AE (24578): Uncompressed 172106 bytes to 1048576 bytes in 144ms!
D/dalvikvm(24578): GC freed 13 objects / 689072 bytes in 54ms
D/dalvikvm(24578): GC freed 4 objects / 240 bytes in 56ms
D/dalvikvm(24578): GC freed 9 objects / 2428128 bytes in 57ms
D/dalvikvm(24578): GC freed 16 objects / 2097656 bytes in 61ms
D/dalvikvm(24578): GC freed 3 objects / 362744 bytes in 55ms
I/jPCT-AE (24578): Uncompressed 181335 bytes to 1048576 bytes in 166ms!
D/dalvikvm(24578): GC freed 13 objects / 727112 bytes in 54ms
D/dalvikvm(24578): GC freed 4 objects / 240 bytes in 56ms
D/dalvikvm(24578): GC freed 15 objects / 2503384 bytes in 58ms
D/dalvikvm(24578): GC freed 10 objects / 2097480 bytes in 56ms
D/dalvikvm(24578): GC freed 3 objects / 366944 bytes in 54ms
I/jPCT-AE (24578): Uncompressed 183437 bytes to 1048576 bytes in 162ms!
D/dalvikvm(24578): GC freed 13 objects / 735776 bytes in 55ms
D/dalvikvm(24578): GC freed 4 objects / 240 bytes in 60ms
D/dalvikvm(24578): GC freed 15 objects / 2521008 bytes in 58ms
D/dalvikvm(24578): GC freed 10 objects / 2097480 bytes in 53ms
D/dalvikvm(24578): GC freed 3 objects / 402048 bytes in 54ms
I/jPCT-AE (24578): Uncompressed 200990 bytes to 1048576 bytes in 163ms!
D/dalvikvm(24578): GC freed 13 objects / 806384 bytes in 57ms
D/dalvikvm(24578): GC freed 4 objects / 240 bytes in 56ms
D/dalvikvm(24578): GC freed 14 objects / 2661304 bytes in 54ms
D/dalvikvm(24578): GC freed 10 objects / 2097480 bytes in 55ms
D/dalvikvm(24578): GC freed 3 objects / 493328 bytes in 53ms
I/jPCT-AE (24578): Uncompressed 246627 bytes to 1048576 bytes in 572ms!
D/dalvikvm(24578): GC freed 13 objects / 988360 bytes in 85ms
D/dalvikvm(24578): GC freed 4 objects / 240 bytes in 53ms
D/dalvikvm(24578): GC freed 15 objects / 3025688 bytes in 56ms
D/dalvikvm(24578): GC freed 11 objects / 2359248 bytes in 53ms
I/jPCT-AE (24578): Uncompressed 130872 bytes to 1048576 bytes in 97ms!
D/dalvikvm(24578): GC freed 13 objects / 524728 bytes in 54ms
D/dalvikvm(24578): GC freed 4 objects / 240 bytes in 59ms
D/dalvikvm(24578): GC freed 15 objects / 2098784 bytes in 78ms
I/jPCT-AE (24578): Pre-warming done!
I/Jumpy3D (24578): changed background to: rock

EgonOlsen

So unloading seems to happen immediately as planned...but are the new ones actually uploaded? I can't spot any mip-map-generation message in the log. Are you not using it or does it come later or is it simply missing? I've updated the jar again with some upload-debug-messages. Please report the outcome.

raft

right, i don't use mipmaps for skybox. as skybox textures are always at the same distance to camera, it seemed a waste.

here is the outout:
V/Jumpy3D (24660): changing background to: jungle
I/System.out(24660): unloading skybox
I/jPCT-AE (24660): Unloaded texture: 38
I/jPCT-AE (24660): Unloaded texture: 39
I/jPCT-AE (24660): Unloaded texture: 40
I/jPCT-AE (24660): Unloaded texture: 41
I/jPCT-AE (24660): Unloaded texture: 42
I/jPCT-AE (24660): Unloaded texture: 43
I/jPCT-AE (24660): Memory usage before compacting: 8282 KB used out of 15175 KB
D/dalvikvm(24660): GC freed 121 objects / 1120600 bytes in 64ms
D/dalvikvm(24660): GC freed 2 objects / 48 bytes in 58ms
I/jPCT-AE (24660): Memory usage after compacting: 7188 KB used out of 15175 KB
I/jPCT-AE (24660): Memory usage after compacting: 7189 KB used out of 15175 KB
I/jPCT-AE (24660): Loading Texture...
D/dalvikvm(24660): GC freed 96 objects / 37456 bytes in 60ms
I/jPCT-AE (24660): Compressed 1048576 bytes to 201021 bytes!
I/jPCT-AE (24660): Loading Texture...
D/dalvikvm(24660): GC freed 115 objects / 2397920 bytes in 56ms
D/dalvikvm(24660): GC freed 7 objects / 224 bytes in 59ms
I/jPCT-AE (24660): Compressed 1048576 bytes to 212247 bytes!
I/jPCT-AE (24660): Loading Texture...
D/dalvikvm(24660): GC freed 107 objects / 2364872 bytes in 57ms
D/dalvikvm(24660): GC freed 7 objects / 224 bytes in 57ms
D/dalvikvm(24660): GC freed 10 objects / 33096 bytes in 57ms
I/jPCT-AE (24660): Compressed 1048576 bytes to 210999 bytes!
I/jPCT-AE (24660): Loading Texture...
D/dalvikvm(24660): GC freed 115 objects / 2397920 bytes in 56ms
D/dalvikvm(24660): GC freed 7 objects / 224 bytes in 56ms
I/jPCT-AE (24660): Compressed 1048576 bytes to 204647 bytes!
I/jPCT-AE (24660): Loading Texture...
D/dalvikvm(24660): GC freed 115 objects / 2397920 bytes in 59ms
D/dalvikvm(24660): GC freed 7 objects / 224 bytes in 57ms
I/jPCT-AE (24660): Compressed 1048576 bytes to 251157 bytes!
I/jPCT-AE (24660): Loading Texture...
D/dalvikvm(24660): GC freed 116 objects / 2398040 bytes in 60ms
D/dalvikvm(24660): GC freed 7 objects / 224 bytes in 58ms
I/jPCT-AE (24660): Compressed 1048576 bytes to 145779 bytes!
I/jPCT-AE (24660): Memory usage before compacting: 10694 KB used out of 15175 KB
D/dalvikvm(24660): GC freed 48 objects / 2362032 bytes in 57ms
D/dalvikvm(24660): GC freed 7 objects / 224 bytes in 61ms
I/jPCT-AE (24660): Memory usage after compacting: 8387 KB used out of 15175 KB
D/dalvikvm(24660): GC freed 14 objects / 402816 bytes in 57ms
I/jPCT-AE (24660): Uncompressed 201021 bytes to 1048576 bytes in 151ms!
D/dalvikvm(24660): GC freed 13 objects / 805904 bytes in 56ms
D/dalvikvm(24660): GC freed 4 objects / 240 bytes in 59ms
I/wpa_supplicant(16599): CTRL-EVENT-SCAN-RESULTS  Ready
D/dalvikvm(24660): GC freed 9 objects / 2660896 bytes in 78ms
I/jPCT-AE (24660): New texture's id is: 38
I/jPCT-AE (24660): New texture uploaded!
D/dalvikvm(24660): GC freed 21 objects / 2097872 bytes in 58ms
D/dalvikvm(24660): GC freed 3 objects / 424568 bytes in 56ms
I/jPCT-AE (24660): Uncompressed 212247 bytes to 1048576 bytes in 172ms!
D/dalvikvm(24660): GC freed 13 objects / 850296 bytes in 59ms
D/dalvikvm(24660): GC freed 4 objects / 240 bytes in 60ms
D/dalvikvm(24660): GC freed 15 objects / 2751024 bytes in 58ms
I/jPCT-AE (24660): New texture's id is: 39
I/jPCT-AE (24660): New texture uploaded!
D/dalvikvm(24660): GC freed 15 objects / 2097696 bytes in 59ms
D/dalvikvm(24660): GC freed 3 objects / 422072 bytes in 57ms
I/jPCT-AE (24660): Uncompressed 210999 bytes to 1048576 bytes in 171ms!
D/dalvikvm(24660): GC freed 13 objects / 845336 bytes in 61ms
D/dalvikvm(24660): GC freed 4 objects / 240 bytes in 57ms
D/dalvikvm(24660): GC freed 15 objects / 2739448 bytes in 56ms
I/jPCT-AE (24660): New texture's id is: 40
I/jPCT-AE (24660): New texture uploaded!
D/dalvikvm(24660): GC freed 15 objects / 2097696 bytes in 57ms
D/dalvikvm(24660): GC freed 3 objects / 409368 bytes in 60ms
I/jPCT-AE (24660): Uncompressed 204647 bytes to 1048576 bytes in 171ms!
D/dalvikvm(24660): GC freed 13 objects / 820952 bytes in 59ms
D/dalvikvm(24660): GC freed 4 objects / 240 bytes in 56ms
D/dalvikvm(24660): GC freed 14 objects / 2691576 bytes in 58ms
I/jPCT-AE (24660): New texture's id is: 41
I/jPCT-AE (24660): New texture uploaded!
D/dalvikvm(24660): GC freed 15 objects / 2097696 bytes in 57ms
D/dalvikvm(24660): GC freed 3 objects / 502384 bytes in 61ms
I/jPCT-AE (24660): Uncompressed 251157 bytes to 1048576 bytes in 180ms!
D/dalvikvm(24660): GC freed 13 objects / 1005568 bytes in 57ms
D/dalvikvm(24660): GC freed 4 objects / 240 bytes in 56ms
D/dalvikvm(24660): GC freed 15 objects / 3060504 bytes in 56ms
I/jPCT-AE (24660): New texture's id is: 42
I/jPCT-AE (24660): New texture uploaded!
D/dalvikvm(24660): GC freed 16 objects / 2389280 bytes in 58ms
I/jPCT-AE (24660): Uncompressed 145779 bytes to 1048576 bytes in 108ms!
D/dalvikvm(24660): GC freed 13 objects / 585128 bytes in 57ms
D/dalvikvm(24660): GC freed 4 objects / 240 bytes in 57ms
D/dalvikvm(24660): GC freed 15 objects / 2220560 bytes in 57ms
I/jPCT-AE (24660): New texture's id is: 43
I/jPCT-AE (24660): New texture uploaded!
I/jPCT-AE (24660): Pre-warming done!
I/Jumpy3D (24660): changed background to: jungle

EgonOlsen

Looks fine...it obviously reuses the texture ids, which is a bit strange (never seen that on the desktop) but shouldn't hurt. I'll have a closer look and try to reproduce this problem...

raft

thanks, please let me know if i can help in any way

EgonOlsen

Can you post a code snippet that shows exactly what you are doing to unload the old and enable the new texture?

raft

sure.

this method is called via GLSurfaceView.queueEvent(Runnable) to make sure it's called in GL thread.
private void changeSkyBox() throws Exception {
Log.v(LOG_TAG, "changing background to: " + background);

TextureBank.unloadSkyBoxTextures(buffer);
MemoryHelper.compact();

TextureBank.loadSkyBoxTextures(glContext, background);
MemoryHelper.compact();
TextureManager.getInstance().preWarm(renderer.buffer);

Log.i(LOG_TAG, "changed background to: " + background);
}


the unloadSkyBoxTextures method:
public static void unloadSkyBoxTextures(FrameBuffer buffer) {
TextureManager tm = TextureManager.getInstance();
if (tm.containsTexture("SB_BACK.JPG")) {
System.out.println("unloading skybox");
tm.removeAndUnload("SB_BACK.JPG", buffer);
tm.removeAndUnload("SB_FRONT.JPG", buffer);
tm.removeAndUnload("SB_LEFT.JPG", buffer);
tm.removeAndUnload("SB_RIGHT.JPG", buffer);
tm.removeAndUnload("SB_BOTTO.JPG", buffer);
tm.removeAndUnload("SB_TOP.JPG", buffer);
}
}



loadSkyBoxTextures method. here context is an interface with desktop and AE implementations. it loads the texture, replaces or adds to TextureManager
public static void loadSkyBoxTextures(Context context, String skyBoxName) throws Exception {
context.loadTexture("SB_BACK.JPG", "/images/skybox/" + skyBoxName + "/sb_back.jpg", Context.ALPHA_DONT_USE, SKYBOX_CREATE_MIPMAP, SKYBOX_COMPRESS, SKYBOX_KEEP_PIXEL_DATA);
context.loadTexture("SB_FRONT.JPG", "/images/skybox/" + skyBoxName + "/sb_front.jpg", Context.ALPHA_DONT_USE, SKYBOX_CREATE_MIPMAP, SKYBOX_COMPRESS, SKYBOX_KEEP_PIXEL_DATA);
context.loadTexture("SB_LEFT.JPG", "/images/skybox/" + skyBoxName + "/sb_left.jpg", Context.ALPHA_DONT_USE, SKYBOX_CREATE_MIPMAP, SKYBOX_COMPRESS, SKYBOX_KEEP_PIXEL_DATA);
context.loadTexture("SB_RIGHT.JPG", "/images/skybox/" + skyBoxName + "/sb_right.jpg", Context.ALPHA_DONT_USE, SKYBOX_CREATE_MIPMAP, SKYBOX_COMPRESS, SKYBOX_KEEP_PIXEL_DATA);
context.loadTexture("SB_BOTTO.JPG", "/images/skybox/" + skyBoxName + "/sb_bottom.jpg", Context.ALPHA_DONT_USE, SKYBOX_CREATE_MIPMAP, SKYBOX_COMPRESS, SKYBOX_KEEP_PIXEL_DATA);
context.loadTexture("SB_TOP.JPG", "/images/skybox/" + skyBoxName + "/sb_top.jpg", Context.ALPHA_DONT_USE, SKYBOX_CREATE_MIPMAP, SKYBOX_COMPRESS, SKYBOX_KEEP_PIXEL_DATA);
}



EgonOlsen

Now i get it...you can't do the replacement that way... ;) If you assign a texture (directly or by one of the loaders), there's a lookup into the TextureManager for the manager's internal ID for this texture's name, i.e.

"wall" -> 1
"floor" -> 2

etc.
When uploading the texture to the GPU, it gets another ID, the GL-ID, i.e.

1 -> 38
2 -> 39

etc.

When doing on unload() for a texture, the GL-ID becomes invalid and is available for reuse. The TextureManager's internal ID is still valid though. But when doing a removeAndUnload(), both IDs become invalid. However, the object using this texture still refers to the, now invalid, internal TextureManager ID. This causes the textures to go white.
Adding a new texture with same name doesn't help, because it will get a new internal ID (there's no history that knows which ID this name was once used for). I.e:

"wall" -> 13
"floor" -> 14

Possible solution: Don't do a removeAndUnload() but simply an unload(). In the loading-method, only load the textures in the first run and do a replaceTexture(...) afterwards. That should fix the problem.
I would really like to fix this in another way, but i can't keep the references to the texture's names in the object itself...it's just to expensive memory and performance wise. I should document it better though.

Hope this helps. 

raft

very well, no problem for me. it works now thanks ;D i've changed skybox a few times and no OutOfMemory yet.

btw, you may want to restrict some more logs to Config.debugOutput too, it's really verbose ;)

EgonOlsen

Quote from: raft on January 17, 2011, 10:47:10 PM
btw, you may want to restrict some more logs to Config.debugOutput too, it's really verbose ;)
I'm actually friend of logging more than i'm a friend of using a debugger... ;) However, i'm open to suggestions. Which log outputs are superfluous in your opinion?