Skip to content

list(pyboy.memory) hangs process #402

@pichenka007gd

Description

@pichenka007gd

Memory Dump Hang During Full Memory Comparison

For emulator testing against real hardware behavior, I'm comparing my emulator's execution with PyBoy using a test script that validates CPU instructions.

Problem Description

  • Initially, I compared only CPU registers cycle-to-cycle
  • Discovered desync issues during 0xF0: LDH A,(a8) instruction where my memory values diverge
  • Switched to full memory comparison for better accuracy:
    gbi_ram = list(gbi.pyboy.memory)
    gb_ram = [gb.memory.read_byte(i) for i in range(0xFFFF)]
    assert gbi_ram == gb_ram

Current Issue

When trying to dump full memory space (0x0000-0xFFFF):

  • ist(gbi.pyboy.memory) and similar approaches hang at "phantom addresses" (e.g., 0xFC12, 0xFE12)
  • Process consumes excessive RAM before freezing
  • Same issue occurs with list(gbi.pyboy.mb)
  • PyBoy's built-in save_state() doesn't provide raw memory access needed for comparison

Specific Challenges

  • Need to access memory with current bank selection state
  • Must handle hardware-mirrored regions properly
  • Avoid memory leaks/hangs during iteration
  • Get raw byte values (not state-serialized format)

How to properly:

  • Iterate full memory space (0x0000-0xFFFF) respecting current memory banking
  • Obtain raw byte values without triggering interrupt

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions