File tree Expand file tree Collapse file tree 8 files changed +20
-14
lines changed Open diff view settings
Expand file tree Collapse file tree 8 files changed +20
-14
lines changed Open diff view settings
Original file line number Diff line number Diff line change @@ -673,13 +673,19 @@ MaybeLocal<Value> AsyncWrap::MakeCallback(const Local<Function> cb,
673673 return ret;
674674}
675675
676- std::string AsyncWrap::MemoryInfoName () const {
676+ const char * AsyncWrap::MemoryInfoName () const {
677677 return provider_names[provider_type ()];
678678}
679679
680680std::string AsyncWrap::diagnostic_name () const {
681- return MemoryInfoName () + " (" + std::to_string (env ()->thread_id ()) + " :" +
682- std::to_string (static_cast <int64_t >(async_id_)) + " )" ;
681+ char buf[64 ];
682+ snprintf (buf,
683+ sizeof (buf),
684+ " %s(%" PRIu64 " :%.0f)" ,
685+ MemoryInfoName (),
686+ env ()->thread_id (),
687+ async_id_);
688+ return buf;
683689}
684690
685691Local<Object> AsyncWrap::GetOwner () {
Original file line number Diff line number Diff line change @@ -209,7 +209,7 @@ class AsyncWrap : public BaseObject {
209209 v8::Local<v8::Value>* argv);
210210
211211 virtual std::string diagnostic_name () const ;
212- std::string MemoryInfoName () const override ;
212+ const char * MemoryInfoName () const override ;
213213
214214 static void WeakCallback (const v8::WeakCallbackInfo<DestroyParam> &info);
215215
Original file line number Diff line number Diff line change @@ -398,7 +398,7 @@ class CryptoJob : public AsyncWrap, public ThreadPoolWork {
398398
399399 AdditionalParams* params () { return ¶ms_; }
400400
401- std::string MemoryInfoName () const override {
401+ const char * MemoryInfoName () const override {
402402 return CryptoJobTraits::JobName;
403403 }
404404
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ class MemoryRetainerNode : public v8::EmbedderGraph::Node {
4444 is_root_node_ = is_root_node;
4545 }
4646
47- const char * Name () override { return name_. c_str () ; }
47+ const char * Name () override { return name_; }
4848 const char * NamePrefix () override { return " Node /" ; }
4949 size_t SizeInBytes () override { return size_; }
5050 // TODO(addaleax): Merging this with the "official" WrapperNode() method
@@ -75,7 +75,7 @@ class MemoryRetainerNode : public v8::EmbedderGraph::Node {
7575
7676 // Otherwise (retainer == nullptr), we set these fields in an ad-hoc way
7777 bool is_root_node_ = false ;
78- std::string name_;
78+ const char * name_;
7979 size_t size_ = 0 ;
8080 v8::EmbedderGraph::Node::Detachedness detachedness_ =
8181 v8::EmbedderGraph::Node::Detachedness::kUnknown ;
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ namespace node {
1717
1818// Set the node name of a MemoryRetainer to klass
1919#define SET_MEMORY_INFO_NAME (Klass ) \
20- inline std::string MemoryInfoName () const override { return #Klass; }
20+ inline const char * MemoryInfoName () const override { return #Klass; }
2121
2222// Set the self size of a MemoryRetainer to the stack-allocated size of a
2323// certain class
@@ -68,7 +68,7 @@ class CleanupHookCallback;
6868 * }
6969 *
7070 * // Or use SET_MEMORY_INFO_NAME(ExampleRetainer)
71- * std::string MemoryInfoName() const override {
71+ * const char* MemoryInfoName() const override {
7272 * return "ExampleRetainer";
7373 * }
7474 *
@@ -119,7 +119,7 @@ class MemoryRetainer {
119119 // where all the edges start from the node of the current retainer,
120120 // and point to the nodes as specified by tracker->Track* calls.
121121 virtual void MemoryInfo (MemoryTracker* tracker) const = 0;
122- virtual std::string MemoryInfoName () const = 0;
122+ virtual const char * MemoryInfoName () const = 0;
123123 virtual size_t SelfSize () const = 0;
124124
125125 virtual v8::Local<v8::Object> WrappedObject () const {
Original file line number Diff line number Diff line change @@ -283,14 +283,14 @@ static void GetActiveResourcesInfo(const FunctionCallbackInfo<Value>& args) {
283283 AsyncWrap* w = req_wrap->GetAsyncWrap ();
284284 if (w->persistent ().IsEmpty ()) continue ;
285285 resources_info.emplace_back (
286- OneByteString (env->isolate (), w->MemoryInfoName (). c_str () ));
286+ OneByteString (env->isolate (), w->MemoryInfoName ()));
287287 }
288288
289289 // Active handles
290290 for (HandleWrap* w : *env->handle_wrap_queue ()) {
291291 if (w->persistent ().IsEmpty () || !HandleWrap::HasRef (w)) continue ;
292292 resources_info.emplace_back (
293- OneByteString (env->isolate (), w->MemoryInfoName (). c_str () ));
293+ OneByteString (env->isolate (), w->MemoryInfoName ()));
294294 }
295295
296296 // Active timeouts
Original file line number Diff line number Diff line change @@ -357,7 +357,7 @@ void Realm::VerifyNoStrongBaseObjects() {
357357 if (obj->IsNotIndicativeOfMemoryLeakAtExit ()) return ;
358358 fprintf (stderr,
359359 " Found bad BaseObject during clean exit: %s\n " ,
360- obj->MemoryInfoName (). c_str () );
360+ obj->MemoryInfoName ());
361361 fflush (stderr);
362362 ABORT ();
363363 });
Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ class TCPWrap : public ConnectionWrap<TCPWrap, uv_tcp_t> {
5050
5151 SET_NO_MEMORY_INFO ()
5252 SET_SELF_SIZE (TCPWrap)
53- std::string MemoryInfoName () const override {
53+ const char * MemoryInfoName () const override {
5454 switch (provider_type ()) {
5555 case ProviderType::PROVIDER_TCPWRAP:
5656 return " TCPSocketWrap" ;
You can’t perform that action at this time.
0 commit comments