The memory on the primary server is not available on the log-shipping replica. And for that matter, the data from the uncommitted transactions does not have be in memory. If there is memory pressure, this pages may be flushed from the cache. Keep in mind that data is written to disk, even if the transaction is not committed. Yes, this means that there will be more work to do in case of a rollback, but the assumption is that transactions commit more often than they roll back.
In the next transaction-log backup that is shipped there may be more data for this transaction, and there may also be the commit-mark. But the uncommitted transactions from the previous log-backup are not present in this backup. This backup only holds log records created after the previous back. This is how the log backup works.
Keep in mind that the primary database has no knowledge the the logs are used for log shipping.