Skip to content

Commit

Permalink
Fix memory leaks and heap size (#1003)
Browse files Browse the repository at this point in the history
Adjust heap size
Fix memory leaks
  • Loading branch information
nickdnk committed Mar 20, 2023
1 parent 55bfb59 commit ddacb6d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 15 deletions.
7 changes: 2 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,8 @@ details.
### New Features / Changes 🎉

1. Get5 is now built with SourceMod 1.11.
2. The JSON "pretty print" spacing string has changed from 4 spaces to 1 tab. This is strictly because there is a 16KB
max buffer size in SourceMod, which we come dangerously close to when posting the full player stats via JSON. If you
play 6v6 or 7v7, you may need to
set [`get5_pretty_print_json 0`](https://splewis.github.io/get5/dev/configuration/#get5_pretty_print_json) to
avoid hitting the limit. You **will** see an error in console if this happens.
2. The JSON "pretty print" spacing string has changed from 4 spaces to 1 tab. This is strictly to reduce the size of the
JSON payload and has no practical effect on the objects.
3. The `get5_mysqlstats` extension now uses a transaction to update stat rows for each player. This improves performance
via reduced I/O between the game server and the database server. It now also runs on the JSON methodmaps provided to
forwards instead of copying the KeyValue stat object.
Expand Down
3 changes: 1 addition & 2 deletions scripting/get5.sp
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,7 @@ public void OnPluginStart() {
InitDebugLog(DEBUG_CVAR, "get5");
LogDebug("OnPluginStart version=%s", PLUGIN_VERSION);

// Because we JSON encode the entire match stats on round end, we change from 4 spaces to a tab when pretty-printing.
// It saves a significant number of bytes, and we're limited to 16K. See SendEventJSONToURL().
// Make JSON payloads smaller by using 1 tab instead of 4 spaces to pretty print.
JSON_PP_INDENT = "\t";

// Because we use SDKHooks for damage, we need to re-hook clients that are already on the server
Expand Down
9 changes: 1 addition & 8 deletions scripting/get5/events.sp
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ void SendEventJSONToURL(const char[] event) {
return;
}

int contentLength = strlen(event);
if (contentLength >= 16383) {
LogError(
"JSON event size exceeds the maximum supported value of 16382 bytes and cannot be sent to your log URL. You should consider setting get5_pretty_print_json 0 to reduce the JSON size.");
return;
}

static char error[PLATFORM_MAX_PATH];
Handle eventRequest = CreateGet5HTTPRequest(k_EHTTPMethodPOST, eventUrl, error);
if (eventRequest == INVALID_HANDLE) {
Expand All @@ -41,7 +34,7 @@ void SendEventJSONToURL(const char[] event) {
return;
}

SteamWorks_SetHTTPRequestRawPostBody(eventRequest, "application/json", event, contentLength);
SteamWorks_SetHTTPRequestRawPostBody(eventRequest, "application/json", event, strlen(event));
SteamWorks_SetHTTPRequestNetworkActivityTimeout(eventRequest, 15); // Default 60 is a bit much.
SteamWorks_SetHTTPCallbacks(eventRequest, EventRequestCallback);
SteamWorks_SendHTTPRequest(eventRequest);
Expand Down

0 comments on commit ddacb6d

Please sign in to comment.