AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Memory leakage caused by not destroying menu properly (https://forums.alliedmods.net/showthread.php?t=333572)

Natsheh 07-22-2021 13:37

Memory leakage caused by not destroying menu properly
 
Error log :-
Spoiler


Code :-

Spoiler

Shadows Adi 07-22-2021 16:00

Re: Invalid array handler
 
Show when array is created and when task is created

Natsheh 07-22-2021 16:15

Re: Invalid array handler
 
its already shown in the code, the problem is some bad algorithm i am sure about it.

Bugsy 07-22-2021 16:43

Re: Invalid array handler
 
Did you try making 1 the minimum valid array handle, instead of 0?

Shadows Adi 07-22-2021 17:59

Re: Invalid array handler
 
Quote:

Originally Posted by Natsheh (Post 2753399)
its already shown in the code, the problem is some bad algorithm i am sure about it.

I mean, when are called. The function name.

CrazY. 07-22-2021 19:54

Re: Invalid array handler
 
Invalid_Array is 0 not -1

Quote:

/**
* Cellarray tag declaration
*
* @note These dynamic arrays are intended to be used for a form of global
* storage without requiring a #define that needs to be increased each
* time the plugin author requires more storage. These are not designed
* to be a full replacement for normal arrays, as those are faster and
* should be used whenever possible.
* @note Plugins are responsible for freeing all Array handles they acquire,
* including those from ArrayClone. Failing to free handles will result
* in the plugin and AMXX leaking memory.
*/
enum Array
{
Invalid_Array = 0
};

Natsheh 07-23-2021 00:32

Re: Invalid array handler
 
So there is a problem caused of memory leak i am assuming some of the arrays are been created are not freed altho i am freeing them in remove_hudtask function which is called when an event occurred now the tasks and hudmsgs are removed but i am not sure if the arrays are freed.

I am going to do some debugging and I'll post the results the only problem is its hard to tell when the error occurs.


Quote:

Originally Posted by Shadows Adi (Post 2753406)
I mean, when are called. The function name.

The function is called when an special event occurs.

Natsheh 07-23-2021 11:59

Re: ArrayCreate returns invalid array index
 
Fixed a small bug but the issue is now alot better.

PHP Code:

if(g_aHUDMSG_DATA 

:arrow:
PHP Code:

if(aHUDMSG_DATA 


Shadows Adi 07-23-2021 14:35

Re: ArrayCreate returns invalid array index
 
1. Make some debugging to make sure that you pass correct array handle ID.

2.
Code:
static index, target, szString[16], aHUDMSG_DATA[Hudmessage_SetTask_Data], iTempArray, iTempArrayItem;     iTempArrayItem = str_to_num(params[ copyc(szString, charsmax(szString), params, ' ') ]);     iTempArray = any:str_to_num(szString);
    ArrayGetArray(any:iTempArray, iTempArrayItem, aHUDMSG_DATA); // Error line.
-->>
    ArrayGetArray(Array:iTempArray, iTempArrayItem, aHUDMSG_DATA); // Error line.

3. I can't see the purpose of using "any:" everywhere, can you explain why are you using? You just get confused by using that.

Natsheh 07-23-2021 15:49

Re: ArrayCreate returns invalid array index
 
Quote:

Originally Posted by Shadows Adi (Post 2753490)
1. Make some debugging to make sure that you pass correct array handle ID.

that not the case it returns an invalid array id because there's a memory leak some how, i am doing some debugs be right back with a solution pretty soon, so far i've tested it and every array been created it gets removed which is a good sign.

Quote:

Originally Posted by Shadows Adi (Post 2753490)
3. I can't see the purpose of using "any:" everywhere, can you explain why are you using? You just get confused by using that.

to avoid compilation warnings, and its not that confusing tbh.


All times are GMT -4. The time now is 12:54.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.