View Issue Details

IDProjectCategoryView StatusLast Update
0000457ServerServerpublic2023-01-30 21:57
Reporterrww Assigned To 
PriorityimmediateSeveritycrashReproducibilityalways
Status closedResolutionfixed 
Summary0000457: Memory Leak - event.preventDefault(); in OnElementStreamIn event
Description

First of all - this memory leak works only on Linux server (1.4.3) version. I tested also on Windows, here ram looks correct.
I see, when someone is online on my server, ram of my server increase to infinite. So, I tired to found, what thing cause that, and I found.

Steps To Reproduce

Exact location of code causing memory leak:

// Stop players getting their own blips
addEventHandler("OnElementStreamIn", (event, element, client) => {
    if (element.isType(ELEMENT_BLIP)) {
        let attachee = element.parent;
        if (attachee != null && attachee == client.player) {
            event.preventDefault(); //   <-------------------------------- This line make memory leak
        }
    }
});

Use Vortrex v-playerblips script to reproduce it (memory leak is only on Linux build).
https://github.com/VortrexFTW/gtac_vortrex/tree/master/v-playerblips

TagsLinux, Server
Game

Activities

rww

2022-12-21 14:01

reporter  

image.png (47,998 bytes)   
image.png (47,998 bytes)   

Vortrex

2022-12-21 14:06

administrator   ~0000322

Edited to use markdown code block

jack9267

2022-12-21 14:09

administrator   ~0000323

The javascript and scripting uses garbage collection to free memory, this is managed by SpiderMonkey when used in javascript. You can force a garbage collection by using collectAllGarbage() in your script for testing the memory usage.

https://wiki.gtaconnected.com/collectAllGarbage

Do not call this function in your code though as you should allow the memory to be freed when efficient. The function exists for debugging purposes and for if a long operation is happening. It already gets invoked if a resource stops/starts/restarts.

Vortrex

2023-01-30 21:57

administrator   ~0000332

This is a non-issue. It's not a "memory leak".
Using event.preventDefault happened to cause more script wraps and stuff that needed to be garbage collected.
Extra garbage collection was added to resource start/stop help reduce memory usage.
Closing bug report.

Issue History

Date Modified Username Field Change
2022-12-21 14:01 rww New Issue
2022-12-21 14:01 rww Tag Attached: Linux
2022-12-21 14:01 rww Tag Attached: Server
2022-12-21 14:01 rww File Added: image.png
2022-12-21 14:06 Vortrex Steps to Reproduce Updated
2022-12-21 14:06 Vortrex Note Added: 0000322
2022-12-21 14:09 jack9267 Note Added: 0000323
2023-01-30 21:57 Vortrex Status new => closed
2023-01-30 21:57 Vortrex Resolution open => fixed
2023-01-30 21:57 Vortrex Note Added: 0000332