InvalidMemoryOperationError@(0)

Vladimir Panteleev via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Nov 17 14:24:35 PST 2014


On Monday, 17 November 2014 at 22:19:04 UTC, Vladimir Panteleev 
wrote:
> On Monday, 17 November 2014 at 16:40:18 UTC, ketmar via 
> Digitalmars-d-learn wrote:
>> On Mon, 17 Nov 2014 15:41:25 +0000
>> Andre via Digitalmars-d-learn 
>> <digitalmars-d-learn at puremagic.com> wrote:
>>
>>> 	~this()
>>> 	{
>>> 		foreach(cp; this._columns)
>>> 		{	
>>> 		}
>>> 	}
>> don't do that in destructors. `_columns` field can be already 
>> collected
>> by GC.
>
> Last I checked, the GC finalizes all dead objects before 
> freeing them. InvalidMemoryOperation indicates that an 
> allocation occurred, where is it?

Found it. opApply is virtual, so the vtable is needed to call it. 
The pointer is cleared during destruction, thus an access 
violation occurs, which is attempted to be translated into a D 
exception. However, when D attempts to allocate it, an 
InvalidMemoryOperation occurs.


More information about the Digitalmars-d-learn mailing list