Advertisement
borkdude

Untitled

Mar 13th, 2020
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1.  
  2. Michiel Borkent Today at 11:40 PM
  3. When I produce a String in a graalvm native library and pass a pointer to it to another language. At what point does that String get garbage collected or freed? So I call free on it myself, and if so, how? (edited)
  4.  
  5.  
  6.  
  7.  
  8. 14 replies
  9.  
  10. Chris Seaton 5 minutes ago
  11. Do you mean from the C API?
  12.  
  13. Michiel Borkent 3 minutes ago
  14. So, I'm returning this value: https://github.com/borkdude/sci/blob/e4e860ee343b025514d2de2d7aa0bea097178983/libsci/src/sci/impl/LibSci.java#L15
  15. And I'm using this value from e.g. C++ or Rust. Who cleans it up eventually? (edited)
  16.  
  17. Chris Seaton 3 minutes ago
  18. Are you familiar with the handles and references in the C API?
  19.  
  20. Michiel Borkent 3 minutes ago
  21. Here is a C++ program that uses this lib:
  22. https://github.com/borkdude/sci/blob/e4e860ee343b025514d2de2d7aa0bea097178983/libsci/src/from_cpp.cpp#L14 (edited)
  23.  
  24. Michiel Borkent 2 minutes ago
  25. Is this the C API for GraalVM or the C API in general?
  26.  
  27. Chris Seaton 2 minutes ago
  28. graal_create_isolate etc
  29.  
  30. Chris Seaton 2 minutes ago
  31. It has handles and references in that API
  32.  
  33. Michiel Borkent 1 minute ago
  34. I'm not really familiar with it. I barely got this stuff working by imitating examples. Where's the best place to read up on it?
  35.  
  36. Chris Seaton 1 minute ago
  37. I'm not massively clear myself, but I know if you returned an object it's alive within the scope of a handle, or reference, scope
  38.  
  39. Chris Seaton 1 minute ago
  40. It's not well-documented anywhere I can find either
  41.  
  42. Chris Seaton 1 minute ago
  43. You probably need to dig into the source code yourself
  44.  
  45. Chris Seaton < 1 minute ago
  46. Some things I want to do seem to be privileged to the API that the polyglot C API uses.
  47.  
  48. Chris Seaton < 1 minute ago
  49. Have you looked at how the Polyglot C API works? It returns string pointers, that may explain it.
  50.  
  51. Michiel Borkent < 1 minute ago
  52. I have looked at it a bit after you pointed me to it.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement