[Plugin] PAWN memory access plugin
#1

PAWN memory access plugin
A successor to https://sampforum.blast.hk/showthread.php?tid=451381


Description
The PAWN memory access plugin allows to allocate and free memory from heap in PAWN.


Project
All of the source code, builds and documentations are located at GitHub: https://github.com/BigETI/pawn-memory
Reply
#2

Good job! It'll be useful
Reply
#3

Nice job.
Reply
#4

10/10 best plugin ever used.
Reply
#5

nice plugin! ++
Reply
#6

I have weak knowledge in c, can it be explained what is the difference between managed and unmanaged if (anyway) I need to delete both of them to prevent memory leak?
Reply
#7

The concept of managed and unmanaged memory is not from C. Allocating managed memory in this context stores extra information such as the validity of a pointer and the size of the allocated block of memory. These information are used on calls to validate input, also on plugin unload all "managed" blocks of memory are freed back to the underlying system. Allocating unmanaged memory in this context doesn't really hold the information of the validity of a pointer, neither the size of the allocated block of memory. This concludes that the operations are faster, but they're prone to get misused by programmers, which then can mess up the working virtual memory space by using invalid pointers or overwriting blocks of memory that were not allocated, or used by different program code. Also "unmanaged" memory is not explicitly freed at plugin unload. The counterpart of MEM_new* and MEM_clone is MEM_delete, where the counterpart of MEM_UM_new* and MEM_UM_clone is MEM_UM_delete.
Reply
#8

What's the advantage of this over your old plugin? Why would I wanna allocate memory on the PAWN heap when I can do the same thing without messing with PAWN's heap in your other plugin?
Reply
#9

Memory is not allocated on PAWN heap memory. It is allocated on the application's heap memory.
Reply
#10

How i get the .dll or .so file? or how can i setup this plugin?

Code:
[debug] Run time error 19: "File or function is not found"
[debug]  MEM_get_val
[debug]  MEM_get_size
[debug]  MEM_get_arr
[debug]  MEM_delete
[debug]  MEM_new_arr
[debug]  MEM_set_val
[debug] Run time error 19: "File or function is not found"
[debug]  MEM_get_val
[debug]  MEM_get_size
[debug]  MEM_get_arr
[debug]  MEM_delete
[debug]  MEM_new_arr
[debug]  MEM_set_val
Reply
#11

Quote:
Originally Posted by DavidZvla
View Post
How i get the .dll or .so file? or how can i setup this plugin?
https://github.com/BigETI/pawn-memory/releases
Reply
#12

Hey! I can feel the power of this plugin, yet not all of us are so geeks to simply understand it all by ourselves. Since you decided to share your work, more details about it would be appreciated.
Reply
#13

Quote:
Originally Posted by v1k1nG
View Post
Hey! I can feel the power of this plugin, yet not all of us are so geeks to simply understand it all by ourselves. Since you decided to share your work, more details about it would be appreciated.
It doesn’t take too much to read, the thread mentions that it’s a successor for a previous version you can simply read that thread for documentation purposes.
Reply
#14

Quote:
Originally Posted by Ritzy
View Post
It doesn’t take too much to read, the thread mentions that it’s a successor for a previous version you can simply read that thread for documentation purposes.
True, but I could be so noob and new that I may be ignoring such habits, and then simply think that I can't understand anything of this because I am so stupid and start thinking that coding is not for me, and only thing I can do is to harvest crops for a living. Sharing means caring too I guess. Note that I don't wanna be a pain in the ass, I was just suggesting to make the thread more user-friendly
Reply
#15

The documentation of the previous release is completly deprecated. Again everything you need is at the pawn-memory GitHub page.
Reply
#16

Quote:
Originally Posted by v1k1nG
View Post
True, but I could be so noob and new that I may be ignoring such habits, and then simply think that I can't understand anything of this because I am so stupid and start thinking that coding is not for me, and only thing I can do is to harvest crops for a living. Sharing means caring too I guess. Note that I don't wanna be a pain in the ass, I was just suggesting to make the thread more user-friendly
It is really simple, register information outside of PAWN - create, use, add, clone, remove, free information. (everything is dynamic, no need to specify sizes and your .amx file will also be smaller, ain't sure about compilation time, I think its also shorter because less calculations of Pawn's heap size and less allocation?)


Basic information from the older version of this plugin wasn't transferred to this thread and indeed very little information was added to describe `why in the hell would I need this plugin and why it exists`

But you might not even need this, in fact, I would actually recommend to not use it if you did not read about it before.
Not knowing what you do can make you a victim of memory leak.


This plugin can be useful if you have large lists, in need of dynamic arrays, just don't want the memory to be calculated on Pawn's heap.
Ain't sure about advanced memory manipulation tho, but with this plugin you can store even bigger data using linked lists (wiki)

But just remember that it is slower than using regular variables/arrays, so this might not be a drop-in solution for everything.


EDIT: you can read about this plugin more here
https://sampforum.blast.hk/showthread.php?tid=477809
Reply
#17

Fast compilation and reduced AMX size was not the goal of this plugin. This plugin simply allows you to allocate and free blocks of memory in runtime, that being said if you have a situation where you need to store "n" amount of cells, where "n" is indeterminate at compilation, this is where you want to allocate in runtime. That is the side effect of reducing AMX sizes. If you use this plugin properly, you don't need to do a workaround for allocating indeterminate array sizes at compilation by using very large arrays. C allocation itself is very fast, and any application that depends on indeterminate memory allocation at compilation (even the AMX virtual machine itself) uses C allocation internally. The reason why this plugin exists alogside its first iteration is because it fixes many use issues with secure memory allocation and user experience by introducing a way better syntax, explained in its documentation. The first iteration still exists because of compatibility reasons for older scripts.

About that tutorial, this was written for the first iteration of the plugin alongside a version of linked lists, which only runs on the first iteration of the plugin, which should be avoided completly.
https://sampforum.blast.hk/showthread.php?tid=645193 and https://sampforum.blast.hk/showthread.php?tid=645194 are releases that work with the second plugin iteration.
Reply
#18

Error on Linux CentOS 7. :/

Code:
/lib/libstdc++.so.6: version `CXXABI_1.3.8' not found
#Edit
I compiled the plugin by CentOS (7) itself and it is now functional.
For others needing it, attach a compiled version of the plugin.
Reply
#19

It would be interesting to know what libstdc++ version is used at your build.

Edit: Your build is now included at GitHub, thank you.
Reply
#20

There should be a "MEM_realloc" function.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)