Forum > Database

Running my code consumes too much RAM memory my computer doesn't have

<< < (2/2)


--- Quote from: josh on November 07, 2021, 01:42:09 am ---the 3 dimensional array should take about 67mb when using int16;
what is the size in bytes of mpinteger ?

--- End quote ---

Yep, while eli's code is likely to be 32bit integer (objfpc mode) we are still going to be struggling to use anything like 3Gig. Declariing them as smallint would help...

I have no idea what mpjntegers are but lets assume (for fun) they are 512bits, the second array is using 4Meg.

No, sorry eli, its got to be a coding issue, not a memory one.



--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---uses windows;{$SetPeFlags(IMAGE_FILE_LARGE_ADDRESS_AWARE )}// is $0020 For 32 bit code on windows gives you at least 4Gb addressable space for a 32bit program on win64 and a maximum of 3GB on win32. But slightly less will be available because of processes and programs. See msdn.
If that is still not enough buy more memory. (Or use the overlapped file API)

Gustavo 'Gus' Carreno:
Hey eli,

Ok, let's do some maths: 2*4096*4096 = 33'554'432 Cells

Let's assume were doing 64b integers: 33554432*64 = 2'147'483'648 bits = 268'435'456 bytes = 256 MB

That's nowhere near 3GB since its only a quarter of a Gig. On that amount of RAM you can have 12 of those matrices, well less since you do need the OS to be running.

And with the second matrix, like Davo mentioned, even with 512 bit integers, that would be only 4MB.

So, it's definitely nothing to do with memory but everything to do with the way you're manipulating that memory.

I'm unaware of how the GMP unit uses those MpIntegers, so I'm not really comfortable blaming the GMP unit just yet.

But, if you're running Windows on a 3GB system, well, how much RAM do you really have free, I wonder. I'm guessing that you have at least some 300MB of spare RAM to run the code and allocate the data space.
If you're able to have Lazarus open and running the code, I'm guessing your system can spare the 300MB...

So, again, back to how your code is manipulating that data.

If you would provide us with a test project, or a subset of your code so we can have a better look at how it's running, maybe we could me of more help.

Hope that helps!!



Thank you all. It seems you are right.

The problem stemmed from the way MpIntegers are to be treated. Actually, MpInteger is a Type of whole numbers having no bound (up to the RAM memory). They are treated well by Gmp unit, with all the useful arithmetical operations. However, when treating them, one must be careful with the operation of assignment, which is not as simple as I thought when I was running my code.

So yes, it was not the RAM memory that made my computer collapse. Anyway, it's okay now. Cheers!


[0] Message Index

[*] Previous page

Go to full version