String Appender Fails (Memory Allocation Failure)

Loopback elliott.darfink at gmail.com
Wed Jul 13 17:55:20 PDT 2011


On 2011-07-14 01:17, David Nadlinger wrote:
> Currently, no memory can be allocated at all during garbage collection
> runs, which is where destructors are usually called.
>
> David

That explains it. Do you know when this feature will be available, if
at all?

Here is another interesting case, where I am using external libraries
(FMOD) in this case.

I have two different cases here, but they have two notable things in
common. Both use WinMain as entry point and they both originate in the
class Foo.

In the first case, I use the class Foo, which has the "Sound"
class as a private member. If foo omits the call to allocate the sound
class no "Memory Allocation Failure" occurs. This error is also avoided
if the two lines in the static destructor of sound is omitted:

FMOD_System_Close(m_system);
FMOD_System_Release(m_system);

How come these external functions generates a Memory Allocation Failure
when they use malloc for their memory allocation? Also worth noticing
is that in the non-static destructor FMOD_Sound_Release is called
without any problems, if the two function calls are omitted.

One other thing; how come no "Memory Allocation Failure" occurs, when
I do not allocate the sound class, since the static de-/constructors
of the class are still called?

In the second case, the exact same functions are called except that
everything takes place in-lined in the Foo constructor.

Case 1: Memory Allocation Failure and Sound destructor is not called.
Case 2: Everything works as expected.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: case1.d
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20110714/b0155dac/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: case2.d
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20110714/b0155dac/attachment-0001.ksh>


More information about the Digitalmars-d-learn mailing list