Archive: System::Alloc question


System::Alloc question
Does anyone know why System::Alloc would not allocate memory? I'm trying to allocate a small amount of memory, but for some reason it won't in the script I wrote. I tried the System.nsi sample script and it worked fine! As far as I can tell, I'm not really doing anything different, however I keep getting 0 back as the result.


Possible reasons are: The system is out of memory or the remaining memory is too much fragmented (that is: there is no continuous block of free memory of the requested size). Both sounds very unlikely in your case, because you say that you are requesting only a "small amount" of memory. So I guess you are doing something wrong. But it's hard to say without seeing your code...


Heh, yeah, that would help if I could post it. It's for a project at work, so I can't do that.

As for running out of memory, yeah, that's not happening. I tried this on a machine with 13Gb free and I'm only trying to allocate 4 bytes, which is the size of the value I'm trying to put into the buffer.

I do figure I'm doing something wrong, however I can't for the life of me figure it out. Every example I found revealed nothing of use. I mainly posted to see if anyone know of any sort of stack size limit/heap size limit/config setting/other that may have an affect on whether or not memory can be allocated.


Well, I tried this, just like the example:

OutFile "TestAlloc.exe"

Section
System::Alloc 4
Pop $0
DetailPrint "4 bytes allocated at $0"
System::Free $0
SectionEnd


And the result seems to work fine:

4 bytes allocated at 2247232
Completed


Something else must go wrong in your installer...