1. Managing memory usage & big sequences
- Posted by cp Feb 03, 2011
- 1242 views
I'm working on an app that will be creating large sequences. By that I mean pushing the limits of memory in 32gb environment. What techniques can I use to test if I have enough memory to create the sequence that the user wants? I was thinking I could do an allocate(x) where x is an estimate of what the user will need and then free it right away - but then just doing the allocate may cause a crash if its too large? Any idea's on how I can monitor and ensure I do not exceed available ram would be appreciated. Thanks
2. Re: Managing memory usage & big sequences
- Posted by LarryMiller Feb 03, 2011
- 1260 views
I am assuming that this is a 64 bit OS as few 32 bit systems can use that much 32 GB RAM. At the present time there is no native 64 bit version of Euphoria, although there is one in development. The major problem you will face then will be the limited 2GB virtual address space available to a 32 bit process. This is completely independent of how much RAM you have. Applications have no knowledge of what physical memory addresses they are using.
The best option would be to wait until the 64 bit version is released. The virtual address space available to a 64 bit process is 8192 GB, at least for Windows. This is also independent of RAM size.
If you attempt to allocate memory and it fails (usually due to a shortage of virtual address space) the function will return zero. There will be no crash unless you attempt to use the invalid address returned. A shortage of RAM would normally result in poor performance, not cause a failure. Exceeding the commit limit would cause a failure but that shouldn't happen with a reasonably sized pagefile.
3. Re: Managing memory usage & big sequences
- Posted by cp Feb 03, 2011
- 1175 views
Sorry should read 32bit not 32gb. In general I'd like to test if there is enough memory for a sequence before I build it as I'm envisioning some users attempting to create sequences > 2or3gb of ram. Sounds like from your response I can safely call allocate(x) where x is an estimate of bytes I think the sequence will need. And if it fails then I can handle w/o crashing the app. Any good points of reference on estimating how much memory a given sequence will need? Would I estimate 4bytes for each numeric value in the sequence? Thanks
4. Re: Managing memory usage & big sequences
- Posted by jaygade Feb 04, 2011
- 1122 views
Figure four bytes per element for integers/characters.
If I'm reading this correctly, then figure sixteen bytes for doubles.