|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How does SoundPlayer manage memory?I'm having a question regarding the memory management of the SoundPlayer class (System.Media.SoundPlayer). I'm using a stream as source for the sound, so the player internally calls the PlaySound api function with the SND_MEMORY flag - together with the SND_ASYNC flag, which is the core problem I'm trying to understand. The byte array read from the stream get's passed as a pointer to the memory location (by the marshaling process). MAIN QUESTION: How does the GC (or whoever) know when the memory can be freed? It has no idea when the playback of the sound is finished (because the api function returns asynchronously so is still playing when returning), but it has to free the memory at some time, doesn't it? I've spend hours analyzing the code of SoundPlayer, but couldn't find out how they're doing that, so if anyone has an idea, I'd be glad to hear... Thanks! Jens |
|||||||||||||||||||||||