Hi all,
I build a Squeak.dll. A main.exe call Squeak.dll, passing in Smalltalk string or selector, Squeak.dll execute it, and return an object pointer to main.exe. main.exe then can use the object, send a message to that object pointer.
I tried with SmallInteger, it works fine, since the object body is within the object header. But for normal object, it is meaningless if I kept object pointer at main.exe. GC will definitely recycle it since there's no reference to that object.
I need to be able to use the object pointer back in Squeak.dll all the time. Any idea how can this be done? Any advise?
Thank you so much in advance.
Ang Beepeng
Hi,
Can anyone help me with this? It is really important for me. I'm trying to achieve something but clearly I haven't have enough knowledge about it.
Thank you very much in advance.
Ang Beepeng
You can use addGCRoot() function so, you don't need to bother that your object is moved around and your pointer to it is invalidated because object has moved to a different location.
It doesn't 'pins' the object in memory, but tell VM that an object pointer, stored at given memory location should be kept healthy. Also, it makes sure that your object will not be GCed , even if there is no other objects referencing it.
On 28 April 2010 08:30, Ang BeePeng beepeng86@yahoo.com wrote:
Hi,
Can anyone help me with this? It is really important for me. I'm trying to achieve something but clearly I haven't have enough knowledge about it.
Thank you very much in advance.
Ang Beepeng
View this message in context: http://forum.world.st/shared-object-between-main-exe-and-Squeak-dll-tp202318... Sent from the Squeak - Dev mailing list archive at Nabble.com.
Hi,
Thank you so much for your suggestion.
addGCRoot() is newly introduce with Squeak 4.0 right? Where can I find example, how to use it? I can't find it in VMMaker, I guess VMMaker is not update with 4.0 yet.
I get access violation at remap(), after I use addGCRoot().
Thanks.
Ang Beepeng
On 4 May 2010 14:45, Ang BeePeng beepeng86@yahoo.com wrote:
Hi,
Thank you so much for your suggestion.
addGCRoot() is newly introduce with Squeak 4.0 right? Where can I find example, how to use it? I can't find it in VMMaker, I guess VMMaker is not update with 4.0 yet.
I get access violation at remap(), after I use addGCRoot().
sqInt * oopCell.
*oopCell = someOop.
addGCRoot(oopCell).
Thanks.
Ang Beepeng
View this message in context: http://forum.world.st/shared-object-between-main-exe-and-Squeak-dll-tp202318... Sent from the Squeak - Dev mailing list archive at Nabble.com.
Hi,
I still get error with addGCRoot(). I have something like this.
*tempPtr = popStack(); addGCRoot(tempPtr);
Value pointed by tempPtr changed, before the next GC. extraRoots[1] is still tempPtr. It shouldn't happen right? Therefore during GC, I get access violation, since the changed value is not an address.
Am I having misunderstanding? What is wrong?
Top of the stack in my case is a float. I think it shouldn't be a problem since it is just an object.
Thank you so much in advance.
Ang Beepeng
Ang BeePeng wrote:
Value pointed by tempPtr changed, before the next GC.
Hi,
Correction, as I follow, GC did touch the pointer and then update pointer at extraRoots, which is fine. But I couldn't follow every single GC, so when I let it runs, the value changed, sometime, somewhere.
What is the limitation?
Thanks.
Ang Beepeng
On 7 May 2010 08:47, Ang BeePeng beepeng86@yahoo.com wrote:
Ang BeePeng wrote:
Value pointed by tempPtr changed, before the next GC.
Hi,
Correction, as I follow, GC did touch the pointer and then update pointer at extraRoots, which is fine. But I couldn't follow every single GC, so when I let it runs, the value changed, sometime, somewhere.
What is the limitation?
Simply just don't use oop directly, but always through pointer. This will ensure that at any moment of time you will access a valid oop , which can be used before next GC happens.
The operations which may trigger GC is following: - creating a new object - store pointer to another object, which currently belongs to old area
so, after one of such operation, make sure that you rereading oop value from your root ptr, which you added using addGCRoot().
Thanks.
Ang Beepeng
View this message in context: http://forum.world.st/shared-object-between-main-exe-and-Squeak-dll-tp202318... Sent from the Squeak - Dev mailing list archive at Nabble.com.
Hi, thanks.
Do you mean I can't just leave pointer to object on extraRoots[], and simply get back to it after some time. That mean, there's no way no keep object out of touch of GC forever. addGCRoot() have temporary effect only, is it true?
Thanks.
Ang Beepeng
On 8 May 2010 11:08, Ang BeePeng beepeng86@yahoo.com wrote:
Hi, thanks.
Do you mean I can't just leave pointer to object on extraRoots[], and simply get back to it after some time. That mean, there's no way no keep object out of touch of GC forever. addGCRoot() have temporary effect only, is it true?
OH.. looks like we're going to move in circles with this. With addGCRoot() you specifying an additional _static_ memory location, where some root oop will be stored. A GC takes this oop into account when marking a heap during mark phase, so your oop can never become a garbage. But as well as any other object, it can be moved in memory due to compaction, and oop value will be updated, while oop will still point to the very same object, but moved into a different memory location. Hence you need an indirection, so you still can access the very same object after GC.
oopPtr = malloc(4);
*oopPtr = someOop; addGCRoot(oopPtr);
oop = *oopPtr; .. do something which may cause GC ... oop' = *oopPtr;
here, when you reading a oop stored in oopPtr, before and after GC, they can be different, but still pointing to same object in object memory.
The temporary effect of addGCRoot() lies in another plane: extra roots table are not persisted within image. So, if you save an image and then restart it, you'll have no any extra roots initially.
Thanks.
Ang Beepeng
View this message in context: http://forum.world.st/shared-object-between-main-exe-and-Squeak-dll-tp202318... Sent from the Squeak - Dev mailing list archive at Nabble.com.
Hi,
thanks for your reply.
I didn't see as you describe. I follow the pointer to that object that I wish to keep. For the first few GC cycle that I follow, the object has been moved, and yes, it is still the same object. That is, pointer in extraRoots[] still the same, oop might be different, but content of the object still the same.
Then I allow VM to run on its own, without quit (no image save, I'm comparing within a single run). Then at some point of time, I look into object body, pointed by oop, which pointed by the pointer in extraRoots[]. It changed. That is why I ask if the effect is temporary.
Thank you so much for replying.
Ang Beepeng
On 8 May 2010 14:56, Ang BeePeng beepeng86@yahoo.com wrote:
Hi,
thanks for your reply.
I didn't see as you describe. I follow the pointer to that object that I wish to keep. For the first few GC cycle that I follow, the object has been moved, and yes, it is still the same object. That is, pointer in extraRoots[] still the same, oop might be different, but content of the object still the same.
Then I allow VM to run on its own, without quit (no image save, I'm comparing within a single run). Then at some point of time, I look into object body, pointed by oop, which pointed by the pointer in extraRoots[]. It changed. That is why I ask if the effect is temporary.
it may change depends on what you storing there, and where you changing it. you can always overwrite an oop , held by extra root pointer by using:
*oopPtr = newOop.
or init it just once.. it depends on what you want to do with it.
I just said, that you should always access an object in following way: [1] oop = *oopPtr;
and only then access its contents:
[2] interpreterProxy fetchPointer: 0 ofObject: oop
and between [1] and [2] there should be no operations which may cause GC, otherwise, you need to do [1] again, to refresh oop value, before attempting [2].
Thank you so much for replying.
Ang Beepeng
View this message in context: http://forum.world.st/shared-object-between-main-exe-and-Squeak-dll-tp202318... Sent from the Squeak - Dev mailing list archive at Nabble.com.
Hi, sorry for bothering again.
Access violation I've got is due to GC, I haven't got chance to retrieve the object I store. Value(an address) pointed by pointer in extraRoots changed, to a non-address value, therefore during incrementalGC() -> remap(), it tries to access to that address and then error.
So, I'm sure the error wasn't cause by me trying to access to the wrong part of the memory. I will make a video of it, so that you can see what I mean. It's just that I'm having problem with making a video right now.
Thanks.
Ang Beepeng
On 8 May 2010 18:34, Ang BeePeng beepeng86@yahoo.com wrote:
Hi, sorry for bothering again.
Access violation I've got is due to GC, I haven't got chance to retrieve the object I store. Value(an address) pointed by pointer in extraRoots changed, to a non-address value, therefore during incrementalGC() -> remap(), it tries to access to that address and then error.
So, I'm sure the error wasn't cause by me trying to access to the wrong part of the memory. I will make a video of it, so that you can see what I mean. It's just that I'm having problem with making a video right now.
i'd say you using an extravagant way to demonstrate the error, instead of just showing a snippets of code :) But do as you think would be better for you.
Thanks.
Ang Beepeng
View this message in context: http://forum.world.st/shared-object-between-main-exe-and-Squeak-dll-tp202318... Sent from the Squeak - Dev mailing list archive at Nabble.com.
Hi,
I have a primitive like this.
sqInt primitiveReturnString(void){ sqInt* tempPtr = 0x111EB8D4; sqInt temp;
temp = popStack(); if(isIntegerObject(temp)) dllMemory[dllResult] = temp; else{ *tempPtr = temp; dllMemory[dllResult] = temp; //I'm not sure what to do with this yet addGCRoot(tempPtr); } pop(1); interpReturn = 1; }
I start up SqueakVM, and execute primitiveReturnString() with a float on top of the stack. After this primitive, SqueakVM is allow to run on its own. And then I got an access violation, with call stack look like this.
Squeak4.dll!markAndTrace(int oop=0) Line 11883 + 0x3 bytes C Squeak4.dll!markPhase() Line 12221 + 0x9 bytes C Squeak4.dll!incrementalGC() Line 5578 C Squeak4.dll!instantiateContextsizeInBytes(int classPointer=275821428, int sizeInBytes=92) Line 6218 C Squeak4.dll!allocateOrRecycleContext(int needsLarge=0) Line 2553 + 0x10 bytes C Squeak4.dll!interpret(int * sharedMemory=0x0015fabc, int rcvr=0, char * selector=0x0015fc54, int arg=1, int result=2) Line 8485 + 0xc bytes C Squeak4.dll!SqueakInterp2(int * sharedMemory=0x0015fabc, int rcvr=0, char * selector=0x0015fc54, int arg=1, int result=2) Line 10 + 0x19 bytes C MainProgram.exe!main() Line 49 + 0x19 bytes C MainProgram.exe!__tmainCRTStartup() Line 586 + 0x19 bytes C MainProgram.exe!mainCRTStartup() Line 403 C kernel32.dll!76b91194() [Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll] ntdll.dll!7767b435() ntdll.dll!7767b408()
or sometimes, it is like this:
Squeak4.dll!incCompMakeFwd() Line 5368 + 0xc bytes C Squeak4.dll!incCompBody() Line 5260 + 0x5 bytes C Squeak4.dll!incrementalGC() Line 5588 C Squeak4.dll!sufficientSpaceAfterGC(unsigned int minFree=202504) Line 23654 C Squeak4.dll!primitiveNew() Line 17781 + 0x9 bytes C
Squeak4.dll!dispatchFunctionPointer(void * aFunctionPointer=0x100403c5)
Line 4097 C Squeak4.dll!interpret(int * sharedMemory=0x001dfd48, int rcvr=0, char * selector=0x001dfee0, int arg=1, int result=2) Line 8458 + 0xb bytes C Squeak4.dll!SqueakInterp2(int * sharedMemory=0x001dfd48, int rcvr=0, char * selector=0x001dfee0, int arg=1, int result=2) Line 10 + 0x19 bytes C MainProgram.exe!main() Line 49 + 0x19 bytes C MainProgram.exe!__tmainCRTStartup() Line 586 + 0x19 bytes C MainProgram.exe!mainCRTStartup() Line 403 C kernel32.dll!76b91194() [Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll] ntdll.dll!7767b435() ntdll.dll!7767b408()
sometimes, it is at remap() as I mention earlier.
At extraRoots[1] I can see 0x111EB8D4, which is still tempPtr. But at 0x111EB8D4, I see some non address value which is for example 0x00000002.
Thanks.
Ang Beepeng
On 5/8/2010 9:54 AM, Ang BeePeng wrote:
sqInt primitiveReturnString(void){ sqInt* tempPtr = 0x111EB8D4; sqInt temp;
temp = popStack(); if(isIntegerObject(temp)) dllMemory[dllResult] = temp; else{ *tempPtr = temp; dllMemory[dllResult] = temp; //I'm not sure what to do with this yet addGCRoot(tempPtr);
^^^^^^^^^^^^^^^^^^^
This is wrong. It needs to be
addGCRoot(&tempPtr); ^^^
The call takes a variable location (pointer to a pointer). The contents of the variable is then updated.
Cheers, - Andreas
} pop(1); interpReturn = 1; }
I start up SqueakVM, and execute primitiveReturnString() with a float on top of the stack. After this primitive, SqueakVM is allow to run on its own. And then I got an access violation, with call stack look like this.
Squeak4.dll!markAndTrace(int oop=0) Line 11883 + 0x3 bytes C Squeak4.dll!markPhase() Line 12221 + 0x9 bytes C Squeak4.dll!incrementalGC() Line 5578 C Squeak4.dll!instantiateContextsizeInBytes(int classPointer=275821428, int sizeInBytes=92) Line 6218 C Squeak4.dll!allocateOrRecycleContext(int needsLarge=0) Line 2553 + 0x10 bytes C Squeak4.dll!interpret(int * sharedMemory=0x0015fabc, int rcvr=0, char * selector=0x0015fc54, int arg=1, int result=2) Line 8485 + 0xc bytes C Squeak4.dll!SqueakInterp2(int * sharedMemory=0x0015fabc, int rcvr=0, char
- selector=0x0015fc54, int arg=1, int result=2) Line 10 + 0x19 bytes C MainProgram.exe!main() Line 49 + 0x19 bytes C MainProgram.exe!__tmainCRTStartup() Line 586 + 0x19 bytes C MainProgram.exe!mainCRTStartup() Line 403 C kernel32.dll!76b91194() [Frames below may be incorrect and/or missing, no symbols loaded for
kernel32.dll] ntdll.dll!7767b435() ntdll.dll!7767b408()
or sometimes, it is like this:
Squeak4.dll!incCompMakeFwd() Line 5368 + 0xc bytes C Squeak4.dll!incCompBody() Line 5260 + 0x5 bytes C Squeak4.dll!incrementalGC() Line 5588 C Squeak4.dll!sufficientSpaceAfterGC(unsigned int minFree=202504) Line 23654 C Squeak4.dll!primitiveNew() Line 17781 + 0x9 bytes C
Squeak4.dll!dispatchFunctionPointer(void * aFunctionPointer=0x100403c5)
Line 4097 C Squeak4.dll!interpret(int * sharedMemory=0x001dfd48, int rcvr=0, char * selector=0x001dfee0, int arg=1, int result=2) Line 8458 + 0xb bytes C Squeak4.dll!SqueakInterp2(int * sharedMemory=0x001dfd48, int rcvr=0, char
- selector=0x001dfee0, int arg=1, int result=2) Line 10 + 0x19 bytes C MainProgram.exe!main() Line 49 + 0x19 bytes C MainProgram.exe!__tmainCRTStartup() Line 586 + 0x19 bytes C MainProgram.exe!mainCRTStartup() Line 403 C kernel32.dll!76b91194() [Frames below may be incorrect and/or missing, no symbols loaded for
kernel32.dll] ntdll.dll!7767b435() ntdll.dll!7767b408()
sometimes, it is at remap() as I mention earlier.
At extraRoots[1] I can see 0x111EB8D4, which is still tempPtr. But at 0x111EB8D4, I see some non address value which is for example 0x00000002.
Thanks.
Ang Beepeng
Hi,
I got access violation with that change.
Always, somewhere
for (i = 1; i <= extraRootCount; i += 1) { oop = (extraRoots[i])[0]; if (!((oop & 1))) { markAndTrace(oop); //*** }
current value of oop is 0, some other time, it is 2.
Thanks.
Ang Beepeng
On 8 May 2010 20:01, Andreas Raab andreas.raab@gmx.de wrote:
On 5/8/2010 9:54 AM, Ang BeePeng wrote:
sqInt primitiveReturnString(void){ sqInt* tempPtr = 0x111EB8D4; sqInt temp;
temp = popStack(); if(isIntegerObject(temp)) dllMemory[dllResult] = temp; else{ *tempPtr = temp; dllMemory[dllResult] = temp; //I'm not sure what to do with this yet addGCRoot(tempPtr);
^^^^^^^^^^^^^^^^^^^
This is wrong. It needs to be
addGCRoot(&tempPtr); ^^^
no, it is right, except that i don't understand the Ang's choice of taking an arbitrary constant to serve as a memory pointer. In fact, its equivalent to: addGCRoot( (sqInt*)0x111EB8D4);
because a pointer value initialized with this constant, and storing a oop at that memory location, obviously, doesn't affects the pointer itself.
The call takes a variable location (pointer to a pointer). The contents of the variable is then updated.
Cheers, - Andreas
} pop(1); interpReturn = 1; }
I start up SqueakVM, and execute primitiveReturnString() with a float on top of the stack. After this primitive, SqueakVM is allow to run on its own. And then I got an access violation, with call stack look like this.
Squeak4.dll!markAndTrace(int oop=0) Line 11883 + 0x3 bytes C Squeak4.dll!markPhase() Line 12221 + 0x9 bytes C Squeak4.dll!incrementalGC() Line 5578 C Squeak4.dll!instantiateContextsizeInBytes(int classPointer=275821428, int sizeInBytes=92) Line 6218 C Squeak4.dll!allocateOrRecycleContext(int needsLarge=0) Line 2553 + 0x10 bytes C Squeak4.dll!interpret(int * sharedMemory=0x0015fabc, int rcvr=0, char * selector=0x0015fc54, int arg=1, int result=2) Line 8485 + 0xc bytes C Squeak4.dll!SqueakInterp2(int * sharedMemory=0x0015fabc, int rcvr=0, char
- selector=0x0015fc54, int arg=1, int result=2) Line 10 + 0x19 bytes C
MainProgram.exe!main() Line 49 + 0x19 bytes C MainProgram.exe!__tmainCRTStartup() Line 586 + 0x19 bytes C MainProgram.exe!mainCRTStartup() Line 403 C kernel32.dll!76b91194() [Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll] ntdll.dll!7767b435() ntdll.dll!7767b408()
or sometimes, it is like this:
Squeak4.dll!incCompMakeFwd() Line 5368 + 0xc bytes C Squeak4.dll!incCompBody() Line 5260 + 0x5 bytes C Squeak4.dll!incrementalGC() Line 5588 C Squeak4.dll!sufficientSpaceAfterGC(unsigned int minFree=202504) Line 23654 C Squeak4.dll!primitiveNew() Line 17781 + 0x9 bytes C
Squeak4.dll!dispatchFunctionPointer(void * aFunctionPointer=0x100403c5)
Line 4097 C Squeak4.dll!interpret(int * sharedMemory=0x001dfd48, int rcvr=0, char * selector=0x001dfee0, int arg=1, int result=2) Line 8458 + 0xb bytes C Squeak4.dll!SqueakInterp2(int * sharedMemory=0x001dfd48, int rcvr=0, char
- selector=0x001dfee0, int arg=1, int result=2) Line 10 + 0x19 bytes C
MainProgram.exe!main() Line 49 + 0x19 bytes C MainProgram.exe!__tmainCRTStartup() Line 586 + 0x19 bytes C MainProgram.exe!mainCRTStartup() Line 403 C kernel32.dll!76b91194() [Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll] ntdll.dll!7767b435() ntdll.dll!7767b408()
sometimes, it is at remap() as I mention earlier.
At extraRoots[1] I can see 0x111EB8D4, which is still tempPtr. But at 0x111EB8D4, I see some non address value which is for example 0x00000002.
Thanks.
Ang Beepeng
On 8 May 2010 19:54, Ang BeePeng beepeng86@yahoo.com wrote:
Hi,
I have a primitive like this.
sqInt primitiveReturnString(void){ sqInt* tempPtr = 0x111EB8D4; sqInt temp;
temp = popStack(); if(isIntegerObject(temp)) dllMemory[dllResult] = temp; else{ *tempPtr = temp; dllMemory[dllResult] = temp; //I'm not sure what to do with this yet addGCRoot(tempPtr); } pop(1); interpReturn = 1; }
what does that constant (0x111EB8D4) means?
Anyways, when you calling addCGRoot with it, it means that VM will look for an oop at address 0x111EB8D4 is this what you intend?
Also, you should not call addCGRoot() multiple times with same address. Do it only once, at your / VM initialization stage. Extra roots table is finite, and if you using this prim in a loop, you will just fill out the extra roots table with same values (0x111EB8D4, in your case).
Here , what i'd probably do on your place (its still unclear what you want.. ):
sqInt primitiveReturnString(void){
static sqInt myRoot; static int initialized = 0;
// also, you better add GC root only once, because a size of extra roots table is finite
if ( initialized == 0) { initialized = 1; myRoot = intepreterProxy->nilObject(). // just put nil object initially addGCRoot(&myRoot); }
// now, all you need to do in your prim is just set the myRoot value: myRoot = popStack();
// and then, pass an _address_ to the root, _not_ oop itself:
dllMemory[dllResult] = &myRoot. }
so, your code (somewhere outside , i guess) can safely access the oop value using:
oop = * ((sqInt*)dllMemory[dllResult])
I start up SqueakVM, and execute primitiveReturnString() with a float on top of the stack. After this primitive, SqueakVM is allow to run on its own. And then I got an access violation, with call stack look like this.
Squeak4.dll!markAndTrace(int oop=0) Line 11883 + 0x3 bytes C Squeak4.dll!markPhase() Line 12221 + 0x9 bytes C Squeak4.dll!incrementalGC() Line 5578 C Squeak4.dll!instantiateContextsizeInBytes(int classPointer=275821428, int sizeInBytes=92) Line 6218 C Squeak4.dll!allocateOrRecycleContext(int needsLarge=0) Line 2553 + 0x10 bytes C Squeak4.dll!interpret(int * sharedMemory=0x0015fabc, int rcvr=0, char * selector=0x0015fc54, int arg=1, int result=2) Line 8485 + 0xc bytes C Squeak4.dll!SqueakInterp2(int * sharedMemory=0x0015fabc, int rcvr=0, char
- selector=0x0015fc54, int arg=1, int result=2) Line 10 + 0x19 bytes C
MainProgram.exe!main() Line 49 + 0x19 bytes C MainProgram.exe!__tmainCRTStartup() Line 586 + 0x19 bytes C MainProgram.exe!mainCRTStartup() Line 403 C kernel32.dll!76b91194() [Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll] ntdll.dll!7767b435() ntdll.dll!7767b408()
or sometimes, it is like this:
Squeak4.dll!incCompMakeFwd() Line 5368 + 0xc bytes C Squeak4.dll!incCompBody() Line 5260 + 0x5 bytes C Squeak4.dll!incrementalGC() Line 5588 C Squeak4.dll!sufficientSpaceAfterGC(unsigned int minFree=202504) Line 23654 C Squeak4.dll!primitiveNew() Line 17781 + 0x9 bytes C
Squeak4.dll!dispatchFunctionPointer(void * aFunctionPointer=0x100403c5)
Line 4097 C Squeak4.dll!interpret(int * sharedMemory=0x001dfd48, int rcvr=0, char * selector=0x001dfee0, int arg=1, int result=2) Line 8458 + 0xb bytes C Squeak4.dll!SqueakInterp2(int * sharedMemory=0x001dfd48, int rcvr=0, char
- selector=0x001dfee0, int arg=1, int result=2) Line 10 + 0x19 bytes C
MainProgram.exe!main() Line 49 + 0x19 bytes C MainProgram.exe!__tmainCRTStartup() Line 586 + 0x19 bytes C MainProgram.exe!mainCRTStartup() Line 403 C kernel32.dll!76b91194() [Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll] ntdll.dll!7767b435() ntdll.dll!7767b408()
sometimes, it is at remap() as I mention earlier.
At extraRoots[1] I can see 0x111EB8D4, which is still tempPtr. But at 0x111EB8D4, I see some non address value which is for example 0x00000002.
Thanks.
Ang Beepeng
View this message in context: http://forum.world.st/shared-object-between-main-exe-and-Squeak-dll-tp202318... Sent from the Squeak - Dev mailing list archive at Nabble.com.
Hi,
Sorry for showing you rubbish earlier, I'm just experimenting with it. This (sqInt* tempPtr = 0x111EB8D4; ) is simply because I can easily put keep my eye on the same address, see if its value changed. I haven't worry about calling the primitive twice, because for now I will always get error after I use addGCRoots().
My purpose for now, is to learn what can I do with addGCRoots(), how do I use it correctly.
Earlier on, I need a way to keep GC from touching my object. That is why I need to learn addGCRoots().
Thanks for helping me.
Ang Beepeng
On Sat, May 08, 2010 at 02:03:41PM +0300, Igor Stasenko wrote:
On 8 May 2010 11:08, Ang BeePeng beepeng86@yahoo.com wrote:
oopPtr = malloc(4);
*oopPtr = someOop; addGCRoot(oopPtr);
oop = *oopPtr; .. do something which may cause GC ... oop' = *oopPtr;
<nitpick> Object memory words might not be size 4, so you probably meant:
oopPtr = malloc(BytesPerWord);
</nitpick>
Dave
squeak-dev@lists.squeakfoundation.org