Update node revision programmatly
When you load a node, you should always check if it exists (is not null) before calling a method:

$node = node_revision_load(59);
if ($node) {
  $node-&gt;set('publish_on', null);
  $node-&gt;save();
}


But this is not the cause for the memory error. This is more likely a recursive thing. For example you are saving again and again until the memory is filled up.