fix: EMERGENCY memory relief for Main Controller Stack-Heap Collision

CRITICAL MEMORY REDUCTION in Main_Controller_Linkset.lsl:

REPLACED HEAVY STRING CONCATENATIONS:
- Emergency cleanup debug messages -> delegated ownerMsg()
- Status message debug -> simple debugMsg()
- Victory sequence debug -> simple ownerMsg()
- Heavy debug loops in updateHelpers() -> single debugMsg()
- Multi-line sync message debug -> simple debugMsg()

MEMORY SAVINGS:
- Eliminated 5+ complex string concatenation operations
- Reduced debug message processing overhead
- Delegated memory-heavy operations to MessageHandler
- Simplified all owner message output

This should immediately reduce Main Controller memory pressure
and resolve the Stack-Heap Collision issue.
This commit is contained in:
RebeccaNod1 2025-09-14 10:04:10 -05:00
parent e6a6f76863
commit 7124089015

View file

@ -250,7 +250,7 @@ checkMemoryUsage(string context) {
} }
emergencyMemoryCleanup() { emergencyMemoryCleanup() {
llOwnerSay("🎆 [Main Controller] Emergency memory cleanup initiated!"); ownerMsg("SUCCESS|Emergency memory cleanup initiated");
globalPickedNumbers = llListSort(globalPickedNumbers, 1, TRUE); globalPickedNumbers = llListSort(globalPickedNumbers, 1, TRUE);
@ -266,8 +266,7 @@ emergencyMemoryCleanup() {
names = tempNames; names = tempNames;
lives = tempLives; lives = tempLives;
llOwnerSay("🎆 [Main Controller] Emergency cleanup complete - memory: " + ownerMsg("SUCCESS|Emergency cleanup complete");
(string)llGetUsedMemory() + " bytes");
} }
reportMemoryStats() { reportMemoryStats() {
@ -293,7 +292,7 @@ sendStatusMessage(string status) {
// CHANGED: Use link message instead of llRegionSay // CHANGED: Use link message instead of llRegionSay
llMessageLinked(SCOREBOARD_LINK, MSG_GAME_STATUS, status, NULL_KEY); llMessageLinked(SCOREBOARD_LINK, MSG_GAME_STATUS, status, NULL_KEY);
llOwnerSay("📢 Status: " + status + " (showing for " + (string)STATUS_DISPLAY_TIME + "s)"); ownerMsg("DEBUG|Status|" + status);
currentTimerMode = TIMER_STATUS; currentTimerMode = TIMER_STATUS;
llSetTimerEvent(STATUS_DISPLAY_TIME + 1.0); llSetTimerEvent(STATUS_DISPLAY_TIME + 1.0);
@ -302,10 +301,10 @@ sendStatusMessage(string status) {
// Forward game state to helpers when it changes // Forward game state to helpers when it changes
updateHelpers() { updateHelpers() {
// Skip sending sync messages during victory sequence to prevent stale data broadcasts // Skip sending sync messages during victory sequence to prevent stale data broadcasts
if (victoryInProgress) { if (victoryInProgress) {
llOwnerSay("🏆 [Main Controller] Skipping updateHelpers during victory sequence"); ownerMsg("DEBUG|Main|Skipping updateHelpers during victory");
return; return;
} }
checkMemoryUsage("updateHelpers_start"); checkMemoryUsage("updateHelpers_start");
@ -320,15 +319,10 @@ updateHelpers() {
picksDataStr = llDumpList2String(picksData, "^"); picksDataStr = llDumpList2String(picksData, "^");
checkMemoryUsage("updateHelpers_after_picks_processing"); checkMemoryUsage("updateHelpers_after_picks_processing");
// DEBUG: Log what we're sending // DEBUG: Simple pick data logging
llOwnerSay("📤 [Main Controller] Sending picks data (" + (string)dataCount + " entries):"); debugMsg("Sending picks data: " + (string)dataCount + " entries");
integer debugIdx;
for (debugIdx = 0; debugIdx < llGetListLength(picksData); debugIdx++) {
llOwnerSay(" [" + (string)debugIdx + "]: " + llList2String(picksData, debugIdx));
}
llOwnerSay("📤 [Main Controller] Encoded picks data: '" + picksDataStr + "'");
} else { } else {
llOwnerSay("📤 [Main Controller] No picks data to send (empty)"); debugMsg("No picks data to send");
} }
// Send core game state to internal scripts (include players list for floater management) // Send core game state to internal scripts (include players list for floater management)
@ -343,7 +337,7 @@ updateHelpers() {
if (playersStr == "") playersStr = "EMPTY_PLAYERS"; if (playersStr == "") playersStr = "EMPTY_PLAYERS";
string syncMessage = livesStr + "~" + picksDataStr + "~" + perilForSync + "~" + namesStr + "~" + playersStr; string syncMessage = livesStr + "~" + picksDataStr + "~" + perilForSync + "~" + namesStr + "~" + playersStr;
llOwnerSay("📤 [Main Controller] Full sync message: " + syncMessage); debugMsg("Full sync message prepared");
// Only send sync if we have actual game data OR it's a proper reset sync // Only send sync if we have actual game data OR it's a proper reset sync
if (llGetListLength(names) > 0 || picksDataStr != "EMPTY" || perilForSync != "NONE") { if (llGetListLength(names) > 0 || picksDataStr != "EMPTY" || perilForSync != "NONE") {