Log message #4183913

# At Username Text
# Apr 18th, 17:27 slackebot -> 23.52 MB Inner loop memory usage run: 5 -> 29.82 MB Inner loop memory usage run: 6 -> 38.11 MB Inner loop memory usage run: 7 -> 44.41 MB Inner loop memory usage run: 8 -> 50.7 MB Inner loop memory usage run: 9 -> 56.99 MB Inner loop memory usage run: 10 -> 67.29 MB Inner loop memory usage run: 11 -> 73.58 MB Inner loop memory usage run: 12 -> 79.67 MB Total loop memory usage -> 82.13 MB It should not be wasting this much memory on each loop, when
# Apr 18th, 17:27 pedrorocha Hello guys, I'm trying to save 320k records on my db using a foreach loop to iterate through an array of data. I loaded the model outside the loop and split the data in batches of 15k, the inner loop looks like this: ```foreach ($users as $user) { $dataToSave = array('user_id' => $user->id, 'notification_id' => $notificationId); $userNotification = $this->UserNotification->newEntity(); $userNotification =
# Apr 18th, 17:27 slackebot $this->UserNotification->patchEntity($userNotification, $dataToSave); $this->UserNotification->save($userNotification); }``` It's wrapped around a while loop counting the number of runs and managing the batches. When I run this code and track the memory usage of it, this is what I'm getting: Inner loop memory usage run: 1 -> 2.61 MB Inner loop memory usage run: 2 -> 9.43 MB Inner loop memory usage run: 3 -> 16.23 MB Inner loop memory usage run: 4
# Apr 18th, 16:32 admad @mrfeedback `<?=` is short echo, different than short open tag. It's unaffected by php config and always available
# Apr 18th, 16:20 mrfeedback `Note that this directive does not control the <?= shorthand tag, which can be ; used regardless of this directive.`
# Apr 18th, 16:20 mrfeedback oh. okay forget what i said
# Apr 18th, 16:18 mrfeedback yep i mean `<?=` as `short_tag_open` is also not recommened as `On` for production environments according to the official php.ini https://github.com/php/php-src/blob/master/php.ini-production
# Apr 18th, 16:14 ricksaccous the second is never used
# Apr 18th, 16:13 ricksaccous @mrfeedback <?= is very distinct from <? ?>
# Apr 18th, 16:13 waspinator never heard of it being a problem before
# Apr 18th, 16:13 waspinator you mean this `<?=`
# Apr 18th, 16:11 waspinator https://github.com/cakephp/cakephp.org/blob/master/src/Template/Element/Layout/default/footer/social_links.ctp
# Apr 18th, 16:09 mrfeedback i mean its used everywhere as it seems :slightly_smiling_face:
# Apr 18th, 16:09 mrfeedback cakephp.org\src\Template\Element\Layout\default\footer\social_links.ctp e.g.
# Apr 18th, 16:08 admad where?
# Apr 18th, 16:08 mrfeedback hmm browsing through templates of cakephp.org i realize that you use shorttags for opening and echoing in php. i was told that this feature is often disabled on hosts due to security concerns. or is this not an actual problem anymore?
# Apr 18th, 16:07 admad then make a PR for the docs :slightly_smiling_face:
# Apr 18th, 16:02 mrfeedback ah funny. on the website itself it is removed. but not in the book
# Apr 18th, 15:56 mrfeedback thx
# Apr 18th, 15:50 admad https://github.com/cakephp/cakephp.org
# Apr 18th, 15:49 mrfeedback hmm i have no idea where to put the PR for the website? :slightly_smiling_face:
# Apr 18th, 15:45 admad @mrfeedback make a PR :slightly_smiling_face:
# Apr 18th, 15:42 mrfeedback i think you can remove the Google+ Button on the website :)
# Apr 18th, 15:38 this.impetus @admad check, will do, ty
# Apr 18th, 15:37 admad @this.impetus you might also want to consider https://github.com/admad/cakephp-glide
# Apr 18th, 14:49 ricksaccous lol
# Apr 18th, 14:49 neon1024 https://github.com/cakephp/cakephp/blob/master/src/Core/ObjectRegistry.php#L97
# Apr 18th, 14:49 ricksaccous well actually that makes sense
# Apr 18th, 14:49 ricksaccous or it didn't instantiate it
# Apr 18th, 14:49 this.impetus It alarms me terribly that I understand none of that :P
# Apr 18th, 14:49 ricksaccous i had no idea that it didn't load it until you used it
# Apr 18th, 14:48 ricksaccous interesting
# Apr 18th, 14:48 neon1024 .. a bit like a DI container
# Apr 18th, 14:48 neon1024 As if it can’t find the key, it’ll instantiate the object and set the instance to the key
# Apr 18th, 14:48 neon1024 At least that’s my understanding of how the object registry works
# Apr 18th, 14:48 neon1024 They don’t get instantiated in the registry until you use them anyway
# Apr 18th, 14:47 neon1024 I think it’s such a microscopic enhancement to selectivly load helpers in the controller method
# Apr 18th, 14:47 neon1024 Loading helpers in the AppView I guess
# Apr 18th, 14:47 neon1024 You shouldn’t be loading helpers in a template file
# Apr 18th, 14:46 ricksaccous but i don't think it makes a huge difference
# Apr 18th, 14:46 ricksaccous @neon1024 it probably makes more sense to manipulate that in the view class especially because the response is available to you there