Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory not clearing, or garbage not being collected? #125

Open
gadget78 opened this issue Mar 3, 2024 · 6 comments
Open

Memory not clearing, or garbage not being collected? #125

gadget78 opened this issue Mar 3, 2024 · 6 comments
Labels
waiting for info waiting for for info from poster

Comments

@gadget78
Copy link

gadget78 commented Mar 3, 2024

im using this bridge within a loop,
i added a require link, so i can call a JS function from within a loop.

but it seems i cannot get the memory it uses on each loop to clear for the next loop,
i have = None all the variables used (and del them too),
i have used gc.collect() at the end of loop,
and i have isolated it just to this java scripted area
(for eg, the data is normally sent to DataBase, but have tested just deleted all data and not sending it, just to rule out circular links)

Every loop its taking roughly 1MB of Ram, so limits me on how much i can process...
if i create a chunk processing loop, to feed this loop that process via the JavaScript, it still hangs on to the ram and wont clear.

are there any tips, or commands i could issue to help clear it after its used ?
could using @ AsyncTask decorators help ?

@extremeheat
Copy link
Owner

What version are you using? Release 1.1.3 last month should have fixed a handler leak. It's possible you're using an older version of the package.

@gadget78
Copy link
Author

gadget78 commented Mar 4, 2024

What version are you using? Release 1.1.3 last month should have fixed a handler leak. It's possible you're using an older version of the package.

looks like im on v1.1.2
will update an see if it helps :)

@gadget78
Copy link
Author

gadget78 commented Mar 4, 2024

updated, and still the same :(
is there any commands i could set to help clear garbage on the javascript side ?
althou i cannot see anything in docs...

@extremeheat
Copy link
Owner

No, can you provide the code to reproduce this issue?

@extremeheat extremeheat added the waiting for info waiting for for info from poster label Mar 4, 2024
@gadget78
Copy link
Author

gadget78 commented Mar 4, 2024

Will get you some sample code that's being looped..
It's calling functions from
https://github.com/EvernodeXRPL/evernode-js-client
And setting up Buffers to feed one of functions too...

So it could be something to do with their code ?..
I will get a the code I'm using/looping once I'm home....

@gadget78
Copy link
Author

gadget78 commented Mar 5, 2024

here is the code that is looped ..

import hooks_toolkit
from hooks_toolkit.libs.keylet_utils.state_utility import StateUtility
from hooks_toolkit.libs.asyncio.keylet_utils.state_utility import StateUtility
from xrpl.asyncio.clients import AsyncWebsocketClient

import javascript
from javascript import require
evernode = require('evernode-js-client')
Buffer = evernode.Buffer

        decoded_host_info = {}

        # create statekey for hostAddr data, and decode it
        statekey_hostAddr = evernode.StateHelpers.generateHostAddrStateKey(rZERpWazEoH3yizJXBePLS4i5bp7Zutia)  
        #print("statekey_hostAddr -->", statekey_hostAddr)

        async with AsyncWebsocketClient(f"wss://xahau.network") as client:
            try:
                hook_state_hostAddr_obj = await StateUtility.get_hook_state(client, self.evernode_governor_account, statekey_hostAddr, self.evernode_governor_namespace)
                statekey_hostAddr = javascript.eval_js(f''' Buffer.from("{statekey_hostAddr}", 'hex') ''')
                stateData_hostAddr = javascript.eval_js(f''' Buffer.from("{hook_state_hostAddr_obj['HookStateData']}", 'hex') ''')
                decoded_hostAddr_js = evernode.StateHelpers.decodeStateData(statekey_hostAddr, stateData_hostAddr)
                for key in decoded_hostAddr_js:
                        decoded_host_info[key] = decoded_hostAddr_js[key]

                # Now we have the hostAddr state key, state data, and decoded that data, We can now use the uriTokenId from that to create statekey, and get statedata for the tokenId info.
                statekey_tokenId = evernode.StateHelpers.generateTokenIdStateKey(decoded_host_info['uriTokenId'])
                hook_state_tokenId_obj = await StateUtility.get_hook_state(client, self.evernode_governor_account, statekey_tokenId, self.evernode_governor_namespace)
                statekey_tokenId = javascript.eval_js(f''' Buffer.from("{statekey_tokenId}", 'hex') ''')
                stateData_tokenId = javascript.eval_js(f''' Buffer.from("{hook_state_tokenId_obj['HookStateData']}", 'hex') ''')
                decoded_tokenId_js = evernode.StateHelpers.decodeStateData(statekey_tokenId, stateData_tokenId)
                for key in decoded_tokenId_js:
                        decoded_host_info[key] = decoded_tokenId_js[key]

i know you probably wanted some smaller lump of code that you could run in your own environment...
think ive provided enough for you to do this pass.. if you just keep doing the same pass, should be same as what im doing,
where i change the rZERpWazEoH3yizJXBePLS4i5bp7Zutia value on each loop, which is whats its all decoding etc etc ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting for info waiting for for info from poster
Projects
None yet
Development

No branches or pull requests

2 participants