<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto">Hi Marcel,<br><div dir="ltr"><br></div><div dir="ltr"><br><blockquote type="cite">On Mar 31, 2023, at 12:49 AM, Marcel Taeumel via Squeak-dev <squeak-dev@lists.squeakfoundation.org> wrote:<br><br></blockquote></div><blockquote type="cite"><div dir="ltr"><div id="__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;color: #000000;text-align: left" dir="ltr">
                                        Hi L --<div><br></div><div>> <span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px">The real question is about setting a pointer to the memory used by a Bitmap object.</span></div><div><span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px"><br></span></div><div><span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px">I would not do that, I don't think it is possible as each project has its own address space. Virtual memory and so on... You cannot simply share pointers between processes. Thus, allocate some inter-process memory and copy initial data (from any Squeak object memory) to there. Then read/write it there.</span></div></div></div></blockquote><div><br></div>While sharing pointers between processes imposes vi strainers it isn’t necessarily impossible.  As long as the memory being shared is shared at the same addresses in all processes then it is safe to use pointers to this memory.<div><br></div><div>This is the basis of VisualWorks’ perm space, they shares most of the image file between processes (shared, when it worked; it stopped working at some point).</div><div><br></div><div>Imagine the image file is loaded at startup by memory mapping, and that it is mapped at the same address. Note that to do so one does NOT have to defeat address space randomization, which is about where the executable is loaded, but where the image file is mapped, which could be at a very high or very low address to avoid ASR collisions with the executable.  And if all objects in the mapped space are marked, and the GC leaves them alone if marked, then this can effectively share an image which is used to run a canned application between multiple instances.  I believe the Pharo team are rifling on this for (their fork of) Spur.</div><div><br></div><div>So this exercise should be considered more generally.  What is most useful?  IMO being able to share objects is best.  Given that sharing arbitrary objects can be difficult I’ll settle for being able to share large non-pointer objects, e.g. ByteArrays, and accessing them directly.</div><div><br><blockquote type="cite"><div dir="ltr"><div id="__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;color: #000000;text-align: left" dir="ltr"><div><span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px"><br></span></div><div><span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px">Best,</span></div><div><span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px">Marcel</span></div><div class="mb_sig"></div><blockquote class="history_container" type="cite" style="border-left-style:solid;border-width:1px; margin-top:20px; margin-left:0px;padding-left:10px;">
                        <p style="color: #AAAAAA; margin-top: 10px;">Am 31.03.2023 00:30:05 schrieb LawsonEnglish <lenglish5@cox.net>:</p><div style="font-family:Arial,Helvetica,sans-serif"><div style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">Thanks. I’ve used FFI before, and have several references to shared memory on the Mac (other OS’s have similar facilities). The real question is about setting a pointer to the memory used by a Bitmap object.<div><br></div><div>Getting FFI to work with the latest version of Mac OS X is often quite painful due to all the security-related hoops you must jump through to give  permission to an app to access libraries outside the app’s own set. I *think* that Apple’s built in shared memory API won’t be as covoluted to use via FFI as other libraries are, but haven’t tested it on Mac OS X 13.x (Ventura).</div><div><br></div><div>The real question is about setting the pointer that a Bitmap (in two or more images) uses. ELiot kindly offered to mentor me through the process of writing plugins. The real question is: am I up for that?</div><div><br></div><div>L</div><div><br><div><blockquote type="cite"><br><br class="Apple-interchange-newline"><div><div id="__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;text-align: left" dir="ltr">
                                        Hi --<div><br></div><div>I would use SqueakFFI and through that interface a system library for memory shared between processes. Maybe through memory-mapped files or similar...</div><div><br></div><div></div><div>[URLS deleted to satisfy my malfunctioning ISP mailing system]</div><div><br></div><div>Once you have your ExternalAddress for that shared memory region, you can start reading and writing bytes from multiple Squeak images. Watch out for synchronization/locking etc.</div><div><br></div><div>Best,</div><div>Marcel</div><div class="mb_sig"></div></div></div></blockquote></div><br></div></div></div></div></blockquote>
                                        </div><span></span><br></div></blockquote></div></body></html>