Skip to content

"Add Term" fails if dictionary size > php memory_limit #277

Description

@sarahmccuan

Describe the bug
If a dictionary is larger than the php memory_limit value, e.g. because of data import, querying it by clicking on a text word fails and results in an error (see screenshot).

To Reproduce
Steps to reproduce the behavior:

  1. Load a large dictionary (>128 mb) - in this case I loaded both large German dictionaries
  2. Load a text to read
  3. Click on an unknown word & click "Add" button
  4. Popup loads for a minute, then errors
Image

in php logs:

GET /api/v1/terms/for-edit?term_id=1&ord=3
  → PHP Fatal error: Allowed memory size ... exhausted in PreparedStatement.php on line 209

<b>Fatal error</b>: Allowed memory size...{"error":true,"message":"An unexpected error occurred",...}

Note, headers are flushed so this shows up as a 200.

Server (please complete)
Server
LWT version v003004002
Web Server Apache/2.4.68 (Debian)
Server Software Apache/2.4.68
Server Location http://localhost:8010
PHP Version 8.4.24
Database
Database name learning-with-texts
Database Size 209.6 MB
MySQL Version 12.1.2-MariaDB-ubu2404
Client API
REST API Version 3.4.2
REST API Release date 2026-08-16

  • OS: Windows
  • Browser: Vivaldi (Chromium)

** Additional info**

I think this is b/c the whole database is getting pulled into memory

SELECT WoID, WoTextLC, WoStatus, WoLemmaLC FROM words WHERE WoLgID = ? AND WoTextLC <> ?

I'll do a bit of poking at different ways to resolve, might make sense to just raise the memory limit & accept that it'll be a slower lookup. Will open a PR if I can come up with something that seems reasonable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdatabaseDatabase-related issues

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions