Skip to content

Conversation

@ahmadov
Copy link
Contributor

@ahmadov ahmadov commented Jan 18, 2019

MemoryManagerReferenceHandler.v8HandleDisposed method is already
implemented with Iterator to compare the object using == instead of
.equals. Therefore,
MemoryManagerReferenceHandler.v8HandleDisposed can be used rather than
ArrayList.remove to remove object from references array.

Fix #444

MemoryManagerReferenceHandler.v8HandleDisposed method is already
implemented with Iterator to compare the object using `==` instead of
`.equals`. Therefore,
MemoryManagerReferenceHandler.v8HandleDisposed can be used rather than
ArrayList.remove to remove object from references array.

Fix #444
Copy link
Member

@irbull irbull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a few small comments. I wonder if you can add a test case for this.

public void release() {
v8.getLocker().checkThread();
if (released) {
if (isReleased()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to change this as part of this commit. We can use the field without the accessor for internal calls.


private void checkReleased() {
if (released) {
if (isReleased()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. See above

v8.getLocker().checkThread();
checkReleased();
references.remove(object);
memoryManagerReferenceHandler.v8HandleDisposed(object);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you include a test case in the MemoryManagerTest that gets the same V8ObjectTwice (so there are two copies of it) and then one is persisted? After we release the MemoryManager one should still remain. I can help you with this if you need help.

Unit tests verify the following cases:
* Persisted object decrease MemoryManager object reference count
* Duplicated object is not managed by MemoryManager when persisted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants