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

Improving memory safety #22

Closed
thomasvergne opened this issue May 18, 2024 · 3 comments · Fixed by #23
Closed

Improving memory safety #22

thomasvergne opened this issue May 18, 2024 · 3 comments · Fixed by #23
Assignees
Labels
bug Something isn't working enhancement New feature or request help wanted Extra attention is needed runtime Related to runtime (JS or VM)
Milestone

Comments

@thomasvergne
Copy link
Member

Plume doesn't deal with memory management within the virtual machine. This is a real issue due to memory leaks, so to resolve this issue, we might implement an algorithm for memory management:

  • Garbage collectors like mark and sweep: easy to implement, but I don't know anything about the performance impact it can have
  • Reference counting like Perceus: less easy to implement but looks like it has better performance

Reference counting seems to be the solution for now, but it requires some modifications in Plume:

  • a new interface drop which would describe two functions: ref, and deref
  • a way to write directly bytecode within Plume code, like raw code, to implement dereferencing operations on object types without the need to allocate a completely new type object with just one field for reference count and another for the value

This solution needs also to resolve issues with primitive types such as int and float. These types do not need to be referenced or dereferenced as they're primitive values, raw values on the stack. This could be achieved either directly during type-checking or during the type-erasure step.

@thomasvergne thomasvergne added bug Something isn't working enhancement New feature or request help wanted Extra attention is needed labels May 18, 2024
@thomasvergne thomasvergne added this to the Plume 1.0 milestone May 18, 2024
@thomasvergne thomasvergne self-assigned this May 18, 2024
@thomasvergne thomasvergne pinned this issue May 18, 2024
@thomasvergne thomasvergne linked a pull request May 20, 2024 that will close this issue
@thomasvergne
Copy link
Member Author

This issue is not completely finished as the current algorithm presents some runtime errors. They are probably dealing with too early freeing.

@thomasvergne thomasvergne reopened this May 20, 2024
@thomasvergne
Copy link
Member Author

thomasvergne commented May 27, 2024

Plume has made great strides in memory safety. We've implemented a very light garbage collector in C with an API that can be used directly from your libraries. Under investigation for leaks, but on the right track!

image

Taken from an example program from Plume repository

@thomasvergne thomasvergne unpinned this issue Jun 14, 2024
@thomasvergne thomasvergne closed this as not planned Won't fix, can't repro, duplicate, stale Jun 14, 2024
@thomasvergne thomasvergne reopened this Jun 14, 2024
@thomasvergne thomasvergne pinned this issue Jun 14, 2024
@thomasvergne
Copy link
Member Author

The previous version generated runtime errors, causing Plume to almost always crash when running a bytecode file. Some changes have been made, such as modifying some factors and default minimum values for the GC.

@thomasvergne thomasvergne added the runtime Related to runtime (JS or VM) label Jun 18, 2024
@linear linear bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request help wanted Extra attention is needed runtime Related to runtime (JS or VM)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant