<body><script type="text/javascript"> function setAttributeOnload(object, attribute, val) { if(window.addEventListener) { window.addEventListener('load', function(){ object[attribute] = val; }, false); } else { window.attachEvent('onload', function(){ object[attribute] = val; }); } } </script> <div id="navbar-iframe-container"></div> <script type="text/javascript" src="https://apis.google.com/js/platform.js"></script> <script type="text/javascript"> gapi.load("gapi.iframes:gapi.iframes.style.bubble", function() { if (gapi.iframes && gapi.iframes.getContext) { gapi.iframes.getContext().openChild({ url: 'https://www.blogger.com/navbar.g?targetBlogID\x3d5974596\x26blogName\x3dWhy?\x26publishMode\x3dPUBLISH_MODE_BLOGSPOT\x26navbarType\x3dBLACK\x26layoutType\x3dCLASSIC\x26searchRoot\x3dhttps://gamindu.blogspot.com/search\x26blogLocale\x3den_US\x26v\x3d2\x26homepageUrl\x3dhttp://gamindu.blogspot.com/\x26vt\x3d8079249296247105828', where: document.getElementById("navbar-iframe-container"), id: "navbar-iframe" }); } }); </script>
Why?

Why the dickens, not? 

Tuesday, March 08, 2005

Arrays

The maximum array size allowed by a language is dependent on the compiler. Everyone knows that. Everyone is told that. And it is true. But have you tried it out? Why should you try it out? Well here are the results of a few hours of blundering around...






CompilerMax Array Size Allowed by Compiler
Turbo C++ 3.064KB
Java Compiler231-1 elements
C#(and other.Net Compilers)264-1 elements
Visual c++~2GB


Note that all these are static array declarations. Java restricts the maximum subscript value to the upperlimit of the primitive datatype int and C# to the upperlimit of the primitive ulong. VC & TC compilers restrict the array size not by a maximum subscript value, but by a maximum size reached by the structure. Although the VC++ compiler allows for the compilation of a structure as big as 2GB, during runtime a block of code can contain only 1MB worth of variable declarations(I'm not sure about this). Also notice that I've said approx. 2GB; while the other compilers allow the sizes mentioned to the dot, VC does not achieve the 2GB limit exactly.

There are those things that nag you for no particular reason. You can either ignore em or go ahead and open pandoras box. But be ready for the difficult questions that follow. I have quite a few of em. why those limits? And whats with VC arrays? without using dynamic allocation, can you really use the 2GB of allocation allowed by the compiler? Educate me! i feel like an ignoramus.

updated text in bold. my face is red.

pp: not really sure about all other .Net compilers; only the ones coming with VS.

urped by gumz @ 3:04 PM


© gumz 2005 - Powered for Blogger by Blogger Templates

Powered by Blogger Weblog Commenting and Trackback by HaloScan.com