AllocString space recycler

Post Reply
User avatar
greenie
Full Member
Full Member
Posts: 4444
Joined: Sun Nov 21, 2021 4:55 pm
Jucator SA:MP ?: Nu
Nick:: greenie
Jucator CS ?: Da

AllocString space recycler

Post by greenie »

[Purpose]
When we create entities, the general method is just like:

new iEntity = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"));

When we use some fakemeta natives such as set_pev, the module automatically calls EngFunc_AllocString to put the string into the memory.

Notice the EngFunc_AllocString, it acts just like : new char[strlen(szValue)+1];
But without delete operation.
This unlimited allocing operation will finally lead to Cache_TryAlloc error and then the server crashes.

[Method]
So here we'd better to recycle those string pointers.
1.Hook EngFunc_AllocString
2.Puts new string to memory using original call and store the result
3.When we need the same string, return the result from previous call

[Installion]
Since register_forward can't hook calls from engfunc, orpheu(or other module) is need, which can be downloaded in https://forums.alliedmods.net/showthread.php?t=116393

Download x_stringman.sma and compile it...and install it.

And you need the function information(no need for signature), put AllocString file into cstrike/addons/amxmodx/configs/orpheu/functions

[CVARs and configs]
None.

[Changelog]
ver 1.1: Destroy Trie in plugin_end()

Allocstring.zip

get plugin or get source
π‘΄π’‚π’šπ’ƒπ’† 𝒕𝒉𝒆 𝑬𝒂𝒓𝒕𝒉 π’Šπ’” 𝒕𝒉𝒆 𝑯𝒆𝒍𝒍 𝒐𝒇 𝑨𝒏𝒐𝒕𝒉𝒆𝒓 𝑷𝒍𝒂𝒏𝒆𝒕... ☒️

βœ… GAZDUIRE JOCURI / VPS / GAZDUIRE WEB / SERVERE DEDICATE - Stock NELIMITAT / Valabil comandati pe https://www.zonek.ro/
Post Reply

Return to β€œAdmin Commands”