Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / memoryblock vs. raw memory

Author
Message
Masqutti
14
Years of Service
User Offline
Joined: 8th Jan 2010
Location: insanity
Posted: 7th Apr 2010 09:56 Edited at: 7th Apr 2010 10:30
Hi!

Is there a any particular reason why I should use raw memory instead of DBpro's memoryblock? I'm planning for pretty huge memory-usage, lets say +500 Mb, and it will be pretty straight forward usage, lots of same structure of data inside the memory. Is there any "uplimit", is there a difference in performance comparing these two? Or any other thing I should think of?

Data saved into a memory will be integers, floats and words.

- masqutti

edit: also, I searched a bit and there seems to be something to do with signed variables. If I have an integer(4bytes) will it be the same 4 bytes in the memblock / memory? like:


Does it make any difference, if I don't use those bytes independently but just read the whole bunch(integer / float / word) without actually knowing what's inside those 4/2 bytes ? Is the float any different?

hmmmh.. that didn't compile
Masqutti
14
Years of Service
User Offline
Joined: 8th Jan 2010
Location: insanity
Posted: 7th Apr 2010 10:37
I'd also like to know, as my system will use the memory to position objects, etc. In theory, principle will be the following:

read the data(object positin and rotation) from the memory, then position/rotate the object.

I have done this by now with a huge array that consist... HUGE amount of objects. How much performance can I achieve with memoryblock/raw memory with this system ? As I have the array thing already working, I just thought if it's worth changing the whole thing to use a raw memory/memblocks?

hmmmh.. that didn't compile
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 8th Apr 2010 16:37
I believe that the built-in memory operations can only handle DWORD adresses, so they are a bit limiting.
Thus, you should be able to store dwords and integers, storing individual bytes, strings etc. is of course also possible however it would require some after processing to break out the relevant parts of the returned dwords. A natural consequence of this is that for storing datatypes of < 4 bytes in size, you have to either squash them together and de-scramble yourself, or just use dwords to store their values (which will take up inecessary memory).

About retrieving signed variables, I would guess that is determined by the datatype you are storing the result to. -1 would become -1 if retrieved to an integer (signed), but (likely) 2147483649 if retrieved to a dword.

Quote: "If I have an integer(4bytes) will it be the same 4 bytes in the memblock / memory?"

Yes.

The first downside to memblocks to consider is that you can only have a limited amount (I believe it is 127 or 255).
Second, it is likely that raw memory access is a bit faster, but that depends on the implementations of the memblock and memory functions I suppose.

I'd really advice to use IanM's memory access command set from his M1U package, as it supports a lot more than the built in 4-bytes only system. It is very fasy as well (not that I have clocked any comparison tests, but it runs fast enough for me, so to say )
I find myself for example needing sets of bitmap font memory, where each character can be stored to raw memory. Since each character has the same dimensions, we can strip off the header of the memory image object. Also, when having a few fonts with ~80 characters each loaded, you would experience the afforementioned memblock limit. Whenever you need to drain the image data out to paste it onto a memblock for making an image from, copy memory works wonders. The same principle goes with all other memblock-supported media.

Quote: "As I have the array thing already working, I just thought if it's worth changing the whole thing to use a raw memory/memblocks?"

There might be a slight speed improvement, but I doubt it is of any relevant impact. As long as you only store relevant information in your array, I'd say keep it as large as it needs to be. If there are blank fields etc. in places you might want to consider a memory solution where you basically have elements telling the sort of data as a word or something, then features a pointer to the relevant data. In that case you can store only as much data for each entity as it needs and strip out the rest.
That would only make sense to be bothered with if you could save a considerable deal of memory that way though, I'd say.

Masqutti
14
Years of Service
User Offline
Joined: 8th Jan 2010
Location: insanity
Posted: 9th Apr 2010 22:53
Thanks for the input!

The memory used with this depends basicly on how much objects are saved, but it might be pretty much. Tho, It's working, and I had some performance issues, but realized it had nothing to do with arrays.. DWORD access only is a bit unuseful but i believe IanM's matrix1 utils work better at this? but thanks, I'll get my project working with arrays first as good as it can be, and if that's not enough, I'll try memoryblocks, or then, raw memory even..

hmmmh.. that didn't compile

Login to post a reply

Server time is: 2024-09-28 16:33:54
Your offset time is: 2024-09-28 16:33:54