Conversation
JoeCap08055
reviewed
Aug 9, 2024
Collaborator
JoeCap08055
left a comment
There was a problem hiding this comment.
Looks good--have you done any testing to see if the finalizer actually does anything?
Collaborator
Author
|
I've done testing but was not able to trigger that. It seems like it's not easy triggering it in Node. If you have any ideas how we might be able to force it to trigger I'm open to ideas. |
Contributor
|
I was not able to reproduce it either , it has weird behavior and unpredictable it will be worth running a load test and let it wait to see if it ever gets triggered |
Collaborator
Author
|
@JoeCap08055 @saraswatpuneet I was able to verify it by directly calling node --expose-gc dist/index.jsfunction interactWithGraph() {
const environment: EnvironmentInterface = {environmentType: EnvironmentType.Mainnet};
for(let i=0;i<10; i++) {
const graph= new Graph(environment);
let public_follow_graph_schema_id = graph.getSchemaIdFromConfig(environment, ConnectionType.Follow, PrivacyType.Public);
let connect_action: ConnectAction = {
type: "Connect",
ownerDsnpUserId: "1",
connection: {
dsnpUserId: "2",
schemaId: public_follow_graph_schema_id,
} as Connection,
dsnpKeys: {
dsnpUserId: "2",
keysHash: 100,
keys: [],
} as DsnpKeys,
} as ConnectAction;
let actions = [] as Action[];
actions.push(connect_action);
let applied = graph.applyActions(actions);
console.log(applied);
let connections_including_pending = graph.getConnectionsForUserGraph("1", public_follow_graph_schema_id, true);
console.log(connections_including_pending);
let exported = graph.exportUpdates();
console.log(exported);
}
if (global.gc) {
global.gc();
} else {
console.log('Garbage collection unavailable. Pass --expose-gc '
+ 'when launching node to enable forced garbage collection.');
}
}which printed |
Contributor
|
Thats a cool thing to know 🥇 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Goal
The goal of this PR is to implement an automated memory cleanup mechanism that might help free the memory in cases that the uses forget to manually free it.
Closes #128