Hi !
First, I'm sorry to post all these memory topics
Well, I try to found a problem, and it's certainly because the ReallocateMemory function doesn't work, so I would like to know what can make this function doesn't work (when i say doesn't work, i mean it doesn't reallocate, it just stay the memory like it was)
thanks a lot !
Can you send a sample code (just a few lines) showing what case you found that does not work. From this we will make tests to confirm or tell you what's wrong ...
Rgrds
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.
Unfortunately, I can't, the code is 1000 lines long, it works with Windows Xp but not with Windows 98... So it's really hard to see where it doesn't work, since it works on one OS, and since i don't get any error (it just doesn't reallocate on Windows 98)
I know it's quite hard to find a problem without sources...
Just I can't do more in this way. But using the debugger will tell you when things work and when do not ...
If you notice a well delimited bad or amazing behaviour, then maybe you can address your code to PureBasic's support for a deeper analysis or send a post here with a limited part of the code where you experience something like that.
Just if you can cut / paste some lines that make the same behaviour, then you will find better help here.
Rgrds
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.
Using ReAllocateMemory() preserves the contents of the old memory space. It may seem that it is not working in several situations:
- You reallocate a large amount of memory to a smaller amount. Since PB preserves the memory's contents, the location of your data in the system's address space will likely not change. PB will simply free the memory that is no longer required by you. However, it will not alter the memory that it frees, and if no other program decides it needs to use that memory, your data will possibly stay in that address space indefinitely. So, you could theoretically read past the smaller size you allocated and still get your old data, but that data has actually been freed.
- You reallocate a small amount of memory to a larger amount. PB will not initialize the new bytes of memory, so they may have garbage data that you need to account for. Also, you might think that resizing some memory to be larger than it was before would mean that the address that the memory is stored in would have to be changed. While this is true in some cases, if you are increasing the memory size by only a few dozen(or possibly even hundreds) of bytes, chances are that the memory directly following the old smaller block of bytes was unclaimed by any application, and PB will simply attach that memory to your already allocated memory. This means that the starting address of your new, bigger data block will remain unchanged, giving the appearance that the reallocation failed. However, do not be alarmed, for it actually succeeded!