@Override
		public boolean applyTo(Program program) {

			Memory mem = program.getMemory();
			Address min = null;
			Address max = null;

			if (!allBlocksInSameSpace()) {
				msg = "All memory block must be in the same address space.";
				return false;
			}

			for (MemoryBlock nextBlock : blocks) {
				if (min == null || nextBlock.getStart().compareTo(min) < 0) {
					min = nextBlock.getStart();
				}
				if (max == null || nextBlock.getEnd().compareTo(max) > 0) {
					max = nextBlock.getEnd();
				}
			}

			if (max == null) {
				return false;
			}

			long size = max.subtract(min) + 1;
			if (size <= 0 || size > Integer.MAX_VALUE) {
				msg = "Resulting Memory Block would be too large.";
				return false;
			}

			try {

				// start with first block
				MemoryBlock bigBlock = blocks.get(0);

				// for each block after
				for (int i = 1; i < blocks.size(); i++) {
					//   get block after
					MemoryBlock nextBlock = blocks.get(i);

					//   create new block for gap in between first block
					Address start = bigBlock.getEnd();
					start = start.addNoWrap(1);
					long length = nextBlock.getStart().subtract(start);
					if (length != 0) {
						MemoryBlock newBlock;
						if (bigBlock.isInitialized()) {
							newBlock = mem.createInitializedBlock(bigBlock.getName(), start, length,
								(byte) 0, null, false);
							newBlock.setRead(bigBlock.isRead());
							newBlock.setWrite(bigBlock.isWrite());
							newBlock.setExecute(bigBlock.isExecute());
							newBlock.setVolatile(bigBlock.isVolatile());
							newBlock.setArtificial(bigBlock.isArtificial());
							newBlock.setSourceName("Resized Memory Block");
						}
						else {
							newBlock = mem.createUninitializedBlock(bigBlock.getName(), start,
								(int) length, false);
						}
						newBlock.setComment(bigBlock.getComment());
						//   join block with gap block
						bigBlock = mem.join(bigBlock, newBlock);
					}

					//  Rename the fragment based on the first block
					renameFragment(program, start, bigBlock.getName());

					//   join block with block after
					bigBlock = mem.join(bigBlock, nextBlock);
				}
				return true;

			}
			catch (RollbackException e) {
				throw e;
			}
			catch (Exception e) {
				msg = e.getMessage();
				if (msg == null) {
					msg = "Error merging blocks: " + e;
				}
			}
			catch (OutOfMemoryError e) {
				msg = "Not enough memory to merge blocks";
			}
			throw new RollbackException(msg);
		}
Delete the list of memory blocks.
@param blocks list of memory blocks to be removed
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/memory/MemoryMapManager.java