In the past, a program could only use a specific part of the computer's memory. If multiple instances of the same program were open, they shared this one memory block. To prevent this, some developers closed their program automatically, if an instance of it was already opened.

Why did this exist? Was it bad for the computer, when a program took up multiple blocks from the memory?

  • 2
    Could you give some concrete examples? – Stephen Kitt Jun 2 '16 at 9:02
  • It was bad as the Rabbit virus from about 1975 existed to clag up memory in exactly that way. – Chenmunka Jun 2 '16 at 9:10
  • @StephenKitt If you ever worked with c++-s WinMain API, you probably came across the remainging parts of this, especially in the main function's parameter list – Bálint Jun 2 '16 at 9:53
  • 2
    I think you should clarify the question (and topic) much more, at the moment it's very vague and will not yield precise answer. – Kuba Tyszko Jun 2 '16 at 12:22
  • 1
    You really need to clarify. Computers could only run one program, period. So if you are referring to some OS, you need to say which. – JDługosz Jun 2 '16 at 13:44

You've referred to Windows, and the question does only make sense on multitasking systems. I believe the reasoning comes not only from the need to save total memory usage but also beliefs at the time about how windowing systems should work: the MDI (multiple document interface) paradigm. So the user would open multiple documents all running within one instance of the program. It would also provide a means of getting back to the already running copy for inexperienced GUI users who'd task-switched away back to the launcher.

For Windows WinMain hPrevInstance there is this: https://devblogs.microsoft.com/oldnewthing/20040615-00/?p=38873

  • This answer is correct even without considering MDI. If the author felt that his program was of a type that did not benefit from having two copies running, then he'd implement this sort of behavior. It was nothing to do with "memory blocks", but an intentional UI decision. Some programs still work like this - like Control Panel on Wiindows 10. – another-dave May 26 '20 at 22:40

I believe you're referring to systems without memory management, and specifically, Operating Systems running on hardware without MMU (memory management unit) and without virtual memory.

Programs are actually pretty fixed when it comes to memory, from the very start (program always starts from a particular address), through execution (memory jumps, branches), until the end (returning from the program).

Virtual memory and MMU allow a program to "think" that it's in a fixed memory space, but in reality the MMU and OS translate those addresses behind the scenes to actual hardware.

Old computers simply didn't have any such hardware or even the need for it, especially when running one program at a time.

Now, I don't think that multiple instances can ever occupy the same memory (block), in a single-tasking system you simply can't run multiple programs, and in a multi-tasking there will always be some piece translating memory between program and hardware.

  • 1
    Software can be relocatable without a MMU or virtual memory; there are various techniques for this, e.g. segmentation (so DOS COM files can be loaded at different addresses in memory) or relocation tables (as used in DOS EXE files). – Stephen Kitt Jun 2 '16 at 12:10
  • 1
    Disagree as well with your last paragraph: Multitasking doesn't necessarily require an implementation of virtual to physical addressing - Operating systems like OS-9 for the Atari or QDOS/SMSQ/E for the Sinclair QL proved in the early 80ies that this is perfectly possible using position-independant code. – tofro Jun 2 '16 at 12:27

If a computer system was capable of running multiple programs simultaneously, it had an OS that could partition memory appropriately. Microcomputers usually couldn't have two programs running.

For a while in the 1970s - 1980s, RAM was the single most expensive component of a computer, and so was fitted sparingly. Programmers had to be very aware of its use.

If you had two copies of the same program running, especially with both trying to access the same peripheral, it had a negative effect. It both slowed the whole system down and would impact availability of the heap. It was also possible, depending upon the program itself, for the two copies to affect each other. Generally speaking, running two copies of a program was pointless and a bad idea.

It was usually a simple check if the programme was already running (it still is) and so worth doing.

  • I think you missunderstood my question, I'm not asking why they firced it to stop, I'm asking why a program could omly have 1 specific memory blocks for multiple instances – Bálint Jun 2 '16 at 9:55
  • If a program had a fixed memory block at an absolute address, then two copies of the program would be a potential disaster. – Chenmunka Jun 2 '16 at 10:27
  • I'm asking why a program could omly have 1 specific memory blocks for multiple instances - This was not the case in Windows. The premise is invalid. – another-dave May 26 '20 at 22:43

Not the answer you're looking for? Browse other questions tagged or ask your own question.