Skip to content

Dynamic memory audit#102

Merged
wjwwood merged 3 commits intomasterfrom
dynamic_memory_audit
Jun 17, 2018
Merged

Dynamic memory audit#102
wjwwood merged 3 commits intomasterfrom
dynamic_memory_audit

Conversation

@wjwwood
Copy link
Copy Markdown
Member

@wjwwood wjwwood commented May 11, 2018

This pull request makes sure that we're using rcutils_allocator_t everywhere and not using malloc, realloc, calloc, or free anywhere at all.

Requires #101

@wjwwood wjwwood added enhancement New feature or request in progress Actively being worked on (Kanban column) labels May 11, 2018
@wjwwood wjwwood self-assigned this May 11, 2018
@dejanpan
Copy link
Copy Markdown

@wjwwood sorry but I can't recall it now - you said that there will be another PR against rcutils after this one?

@wjwwood
Copy link
Copy Markdown
Member Author

wjwwood commented May 12, 2018

Yes, I will probably make it another one rather than combining it into this.

@wjwwood wjwwood force-pushed the dynamic_memory_audit branch from 266ef58 to 70baef0 Compare June 15, 2018 22:30
@wjwwood wjwwood added in review Waiting for review (Kanban column) and removed in progress Actively being worked on (Kanban column) labels Jun 15, 2018
@wjwwood
Copy link
Copy Markdown
Member Author

wjwwood commented Jun 15, 2018

If anyone has time to review these, that would be appreciated! 👍

CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@dejanpan
Copy link
Copy Markdown

@serge-nikulin could you do it please?

@@ -1,42 +0,0 @@
// Copyright 2017 Open Source Robotics Foundation, Inc.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why was this file removed?

I tried to find any mention but I couldn't.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just replaced all use of it with rcutils_format_string(), so it's unnecessary now.

}
const size_t size = 1024;
g_last_log_event.message = malloc(size);
g_last_log_event.message = allocator.allocate(size, allocator.state);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so free resp. malloc are now called inside deallocate resp allocate?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

@wjwwood wjwwood added in progress Actively being worked on (Kanban column) and removed in review Waiting for review (Kanban column) labels Jun 16, 2018
@wjwwood
Copy link
Copy Markdown
Member Author

wjwwood commented Jun 16, 2018

Sorry, there are some missing, but related pull requests for this one. I'll fix it up and ask for review again.

@dejanpan
Copy link
Copy Markdown

@wjwwood one more Q. I tried to find coverage information for rcutils but could only find this https://ci.ros2.org/job/ci_linux_coverage/2/cobertura/src_ros2_rcutils_src/ which seems a bit old.

@wjwwood
Copy link
Copy Markdown
Member Author

wjwwood commented Jun 16, 2018

@serge-nikulin you're welcome to review it too, but I do need someone from our team to review it as well.

@wjwwood one more Q. I tried to find coverage information for rcutils but could only find this https://ci.ros2.org/job/ci_linux_coverage/2/cobertura/src_ros2_rcutils_src/ which seems a bit old.

There's no coverage information still. We have what you linked to, but it's also not trusty worthy right now.

@wjwwood wjwwood added in review Waiting for review (Kanban column) and removed in progress Actively being worked on (Kanban column) labels Jun 16, 2018
@serge-nikulin
Copy link
Copy Markdown

@dejanpan, when do you need the review?


static char cwd[1024];

static rcutils_allocator_t g_allocator = rcutils_get_default_allocator();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not actually changed in this patch but shouldn't all allocated return values be freed here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, looks like there are some memory leaks in that test, I'll clean them up.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, those were really bad leaks. I think 717e044 fixed them.

@wjwwood
Copy link
Copy Markdown
Member Author

wjwwood commented Jun 16, 2018

Ok, in review again, new CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

Copy link
Copy Markdown
Member

@dirk-thomas dirk-thomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@wjwwood
Copy link
Copy Markdown
Member Author

wjwwood commented Jun 17, 2018

I could still use reviews of some of the other pr's associated with this pull request.

New CI after fix up:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@wjwwood wjwwood merged commit ae9be8f into master Jun 17, 2018
@wjwwood wjwwood deleted the dynamic_memory_audit branch June 17, 2018 05:05
@wjwwood wjwwood removed the in review Waiting for review (Kanban column) label Jun 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants