View Issue Details

IDProjectCategoryView StatusLast Update
0003084FSSCPscriptingpublic2014-08-05 17:15
Reporterngld Assigned To 
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.7.2 RC3 
Summary0003084: Bitmaps loaded with gr.loadTexture() are never released.
Descriptiongr.loadTexture() returns a texture handle. The handle has an unload method which calls bm_unload() but not bm_release().
Since the unload method invalidates the Lua handle it should be calling bm_release() instead.
Steps To ReproduceLoad a bunch of ANIs or bitmaps with gr.loadTexture() and use the unload() method to unload them. Type bm_frag in the debug console and note that the bitmaps weren't released.
Additional InformationTo fix this bug the two calls to bm_unload() in code/parse/lua.cpp have to be replaced with bm_release() calls.
The calls are on line 3352 and 3423 as of revision 10968.
TagsNo tags attached.

Activities

Parias

2014-08-05 16:17

developer   ~0016171

Just to drop a supplementary note - I applied these changes to resolve a memory usage problem that occurred when a number of images were loaded sequentially with gr.loadTexture(), where after a certain point my handles spontaneously started coming up as invalid / nil. Applying some aggressive unload() calls between each invocation didn't seem to resolve the issue. This was a critical blocker for a mod / campaign I'm working on.

After replacing bm_unload() with bm_release() in lua.cpp as suggested here and recompiling, the problem seemed to be resolved. Full details in this thread: http://www.hard-light.net/forums/index.php?topic=87993.msg1758523#msg1758523

Parias

2014-08-05 16:24

developer  

lua.cpp-unloadfix.patch (650 bytes)   
Index: code/parse/lua.cpp
===================================================================
--- code/parse/lua.cpp	(revision 10927)
+++ code/parse/lua.cpp	(working copy)
@@ -3349,7 +3349,7 @@
 	// use, and in order to prevent that we want to double-check the load count
 	// here before unloading the bitmap. -zookeeper
 	if(idx > -1 && bm_is_valid(idx) && bm_bitmaps[bm_get_cache_slot(idx, 0)].load_count < 1)
-		bm_unload(idx);
+		bm_release(idx);
 
 	return ADE_RETURN_NIL;
 }
@@ -3419,7 +3419,7 @@
 	if(!bm_is_valid(*idx))
 		return ADE_RETURN_NIL;
 
-	bm_unload(*idx);
+	bm_release(*idx);
 
 	//WMC - invalidate this handle
 	*idx = -1;
lua.cpp-unloadfix.patch (650 bytes)   

Parias

2014-08-05 16:24

developer   ~0016172

.patch uploaded of changes as requested.

m_m

2014-08-05 17:15

developer   ~0016174

Fix committed to trunk@10970.

Related Changesets

fs2open: trunk r10970

2014-08-05 13:42

m_m


Ported: N/A

Details Diff
From ngld and Parias: Fix for Mantis 3084: Bitmaps loaded with gr.loadTexture() are never released. Affected Issues
0003084
mod - /trunk/fs2_open/code/parse/lua.cpp Diff File

Issue History

Date Modified Username Field Change
2014-08-05 10:48 ngld New Issue
2014-08-05 16:17 Parias Note Added: 0016171
2014-08-05 16:24 Parias File Added: lua.cpp-unloadfix.patch
2014-08-05 16:24 Parias Note Added: 0016172
2014-08-05 17:15 m_m Changeset attached => fs2open trunk r10970
2014-08-05 17:15 m_m Note Added: 0016174
2014-08-05 17:15 m_m Status new => resolved
2014-08-05 17:15 m_m Resolution open => fixed