NewStringUTF() creates a new java.lang. String -- in other words, an object on the Java heap, which will get collected when there are no more references to it.
NewStringUTF() creates a new java.lang. String -- in other words, an object on the Java heap, which will get collected when there are no more references to it. Or are you asking about otherString?
I don't know what FormatMessage does, but it looks like it's allocating memory on the C heap. If that's the case, then yes, you have to explicitly free that memory. You make your life harder by sometimes setting otherString to a constant string.
Don't do that. Instead, call NewStringUTF() within the blocks of your if/else, and in the second case free the native C string.
Thanks for the tips, I updated the code if you could have a look and see if you spot any obvious errors (im a java guy workin in a c++ world right now) – Petey B Oct 7 '09 at 20:11 You still don't seem to be freeing lpMsgBuf. Perhaps you don't have to; I don't know whether the FormatMessage() method allocates memory or not. – kdgregory Oct 7 '09 at 20:39 thanks kdgregory, as I understand it lpMsgBuf does not need to be freed, but that's neither here nore there if the rest is correct, thanks again – Petey B Oct 7 '09 at 20:42 Actually it does: see the documentation at msdn.microsoft.Com/en-us/library/ms679351%28VS.85%29.
Aspx regarding FORMAT_MESSAGE_ALLOCATE_BUFFER – kdgregory Oct 7 '09 at 21:47.
You don't have to worry about the memory allocated by NewStringUTF as that will be taken care of by the Java garbage collector. But you have to free the lpMsgBuf as you are passing FORMAT_MESSAGE_ALLOCATE_BUFFER to FormatMessage (i.e. You have to use LocalFree to free that buffer), see the FormatMessage documentation.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.