4 Replies - 340 Views - Last Post: 18 July 2015 - 02:29 AM

#1 adamchalkley  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 17-July 15

need help with memory basics.

Posted 17 July 2015 - 11:20 AM

Hi guys first off I want to introduce myself I am new to the forum :P I'm relatively new to programming but i know the basics and can write simple programs and understand the concepts of classes,methods/functions,inheritance,composition etc but one thing I want to know about which is confusing me the most is about memory and how it works,I know some basics as how to memory is stored in cells of a byte and each block of memory has its own address like 0x036363 and I understand how ASCII works but what I don't get is how the memory works exactly,

I understand what the stack and the heap is as to when methods and objects are created(heap) and how they are popped off the stack and the control is returned to the level below when its done and I also understand how memory is stored in each cell and how its treated BUT what I don't understand is why there would be a stack I thought the CPU is instructed by the program counter what memory location its next execution would be,what would the need for the stack if that's the case would it choose memory locations with the highest address to execute next then? and how do all these programs running in memory work do they stay in the same memory addresses while they are running or do they constantly move for example the chrome browser I am using now,could anyone try to explain this to me in terms as simple as possible or even with the aid of images or a diagram also anyway thanks I really appreciate your time =) Thanks.

Is This A Good Question/Topic? 0
  • +

Replies To: need help with memory basics.

#2 andrewsw  Icon User is online

  • I'm not here to twist your niblets
  • member icon

Reputation: 4541
  • View blog
  • Posts: 16,724
  • Joined: 12-December 12

Re: need help with memory basics.

Posted 17 July 2015 - 11:24 AM

I have removed "Hi new to the forum " from your topic title, it doesn't belong as part of a descriptive title.
Was This Post Helpful? 0
  • +
  • -

#3 adamchalkley  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 17-July 15

Re: need help with memory basics.

Posted 17 July 2015 - 11:59 AM

View Postandrewsw, on 17 July 2015 - 11:24 AM, said:

I have removed "Hi new to the forum " from your topic title, it doesn't belong as part of a descriptive title.


thanks,could you try help answer the actual question though???
Was This Post Helpful? 0
  • +
  • -

#4 macosxnerd101  Icon User is online

  • Games, Graphs, and Auctions
  • member icon




Reputation: 11315
  • View blog
  • Posts: 42,632
  • Joined: 27-December 08

Re: need help with memory basics.

Posted 17 July 2015 - 12:06 PM

Moved to Software Development for better visibility, since this isn't a Java question.

A preliminary search turned up some good results:
http://gribblelab.or...ck_vs_Heap.html
http://www.programme...stack-and-heap/
http://www-ee.eng.ha...ion2.1.1.8.html
Was This Post Helpful? 0
  • +
  • -

#5 cfoley  Icon User is online

  • Cabbage
  • member icon

Reputation: 2198
  • View blog
  • Posts: 4,622
  • Joined: 11-December 07

Re: need help with memory basics.

Posted 18 July 2015 - 02:29 AM

The simple model you described of an execution pointer going through memory works well enough and you can even do things like goto. However when you want to implement functions that can return to the prevois poit of execution you need somewhere to store the value of the execution pointer that you nedd to return to. Consider that you want to be able to call functions several levels deep and a stack becomes the natural data structure to deal with it. Add in local variables and the best place to store them is the stack.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1