Page 1 of 1

Using Magic_OpenFileInMemory. Memory management question.

PostPosted: Wed Aug 25, 2010 5:16 pm
by Nomad
Hello.

Will Magic_CloseFile() release the buffer which I pass to Magic_OpenFileInMemory()?

Memory management question is not covered in docs at all for Magic_OpenFileInMemory() function.

Thanks

Re: Using Magic_OpenFileInMemory. Memory management question.

PostPosted: Wed Aug 25, 2010 6:25 pm
by Odin_KG
Hello

Will Magic_CloseFile() release the buffer which I pass to Magic_OpenFileInMemory()?

Magic_CloseFile() releases the buffer.

Memory management question is not covered in docs at all for Magic_OpenFileInMemory() function.

Ok. I will add this information in new version of the manual.

Re: Using Magic_OpenFileInMemory. Memory management question.

PostPosted: Thu Aug 26, 2010 4:01 am
by Odin_KG
I am sorry. I did not understand question. Magic_CloseFile does not release the buffer. Magic_CloseFile releases information about file, which was loaded from this buffer. You need to use delete []buffer.

Re: Using Magic_OpenFileInMemory. Memory management question.

PostPosted: Thu Aug 26, 2010 3:01 pm
by Nomad
hm..

I tried to delete[] buffer.
But it seems that it changes in some of Magic Particles API calls, because when I call delete[], my app either hangs or breaks on corrupted heap exception.

I will research this issue further to give you more information on this.

Re: Using Magic_OpenFileInMemory. Memory management question.

PostPosted: Thu Aug 26, 2010 3:10 pm
by Nomad
Sorry.
That was my bug.
Now I'm releasing the buffer after Magic_CloseFile() call and all works just fine.
Thanks.

Re: Using Magic_OpenFileInMemory. Memory management question.

PostPosted: Thu Aug 26, 2010 4:54 pm
by Odin_KG
Thanks.

You are welcome.