0

I know that access to computer memory, e.g. Hard and RAM, is in blocking manner. I mean in each access, a block of data will fetch. I do not know what the name of this feature to search it in web! Well I have a program that reads some names (i.e. some strings) from an array. I know that if there is 100 character for a string, we have not 100 times memory access, but I do not know how many memory access we have. I will be glad if you can help me to find it out.

strings are in the array, continuously (e.g. |b|o|o|k|-1|g|i|r|l|-1|w|i|n|t|e|r|) I thinks we have not 4 memory access for reading book, am I right?

Infinite Recursion
  • 6,511
  • 28
  • 39
  • 51
Chavoosh
  • 425
  • 4
  • 15
  • It depends how you define "memory access" (number of loads? number of cache misses? number of main memory fetches? etc.), and then it probably also depends on what platform you're talking about... – Oliver Charlesworth Dec 25 '13 at 15:11
  • There's a memory hierarchy - cache, RAM, then disk. How are you defining "memory access"? – Harry Dec 25 '13 at 15:13
  • 1
    It sounds like you are trying to optimize for cache friendliness, http://stackoverflow.com/questions/16699247/what-is-cache-friendly-code seems to have some good answers. – flaviut Dec 25 '13 at 15:13
  • My OS is Windows 7 and my RAM is DDR3. Actually I did not define "memory access" in my program, because I do not know how I can do it. – Chavoosh Dec 25 '13 at 15:17

1 Answers1

1

If I am interpreting your question correctly, you are asking:

As an example, given a string of 100 characters in a contiguous array within a program, how many times will the system read from RAM, will it be 100 times to enumerate that string (eg: will the system read each byte separately?) or will it be less {chunking sections at a time}?

If that is your question, your answer here will depend heavily on the type of characters that are being stored (ASCII? UTF-8, UTF-16, etc), the underlying system architecture, caching and the associated language used for the program. Just because you have stored something in a contiguous array "inside" a program does not necessarily mean that it will be stored that way in RAM. I believe your question is too vague to be answered in full.

Damien
  • 1,490
  • 1
  • 8
  • 17
  • You interpreted it exactly right. Now I understand there is not one parameter for reading from RAM and as you said it depends on many situation... – Chavoosh Dec 25 '13 at 16:33
  • Thank you. If you believe your question has been answered, can you please mark it as answered? – Damien Dec 25 '13 at 16:55