دسترسی نامحدود
برای کاربرانی که ثبت نام کرده اند
برای ارتباط با ما می توانید از طریق شماره موبایل زیر از طریق تماس و پیامک با ما در ارتباط باشید
در صورت عدم پاسخ گویی از طریق پیامک با پشتیبان در ارتباط باشید
برای کاربرانی که ثبت نام کرده اند
درصورت عدم همخوانی توضیحات با کتاب
از ساعت 7 صبح تا 10 شب
ویرایش: [1 ed.]
نویسندگان: Joseph Babcock. Raghav Bali
سری:
ISBN (شابک) : 9781805129806
ناشر: Packt Publishing
سال نشر: 2025
تعداد صفحات: 434
زبان: English
فرمت فایل : PDF (درصورت درخواست کاربر به PDF، EPUB یا AZW3 تبدیل می شود)
حجم فایل: 33 Mb
در صورت تبدیل فایل کتاب C++ Memory Management: Write leaner and safer C++ code using proven memory-management techniques به فرمت های PDF، EPUB، AZW3، MOBI و یا DJVU می توانید به پشتیبان اطلاع دهید تا فایل مورد نظر را تبدیل نمایند.
توجه داشته باشید کتاب C مدیریت حافظه: کد C لاغر و ایمن تر را با استفاده از تکنیک های مدیریت حافظه اثبات شده بنویسید نسخه زبان اصلی می باشد و کتاب ترجمه شده به فارسی نمی باشد. وبسایت اینترنشنال لایبرری ارائه دهنده کتاب های زبان اصلی می باشد و هیچ گونه کتاب ترجمه شده یا نوشته شده به فارسی را ارائه نمی دهد.
Cover Untitled Foreword Contributors Table of Contents Preface Part 1: Memory in C++ Chapter 1: Objects, Pointers, and References Technical requirements Representation of memory in C++ Objects, pointers, and references Understanding the fundamental properties of objects Object lifetime Object size, alignment, and padding Copy and movement Arrays Summary Chapter 2: Things to be Careful With Different kinds of evil Ill-formed, no diagnostic required Undefined behavior Implementation-defined behavior Unspecified behavior (not documented) The ODR Erroneous behavior Pointers Uses of pointer arithmetic within an array Pointer interconvertibility Uses of pointer arithmetic within an object Type punning Type punning through members of a union The intptr_t and uintptr_t types The std::memcpy() function The special cases of char*, unsigned char*, and std::byte* The std::start_lifetime_as() function Summary Chapter 3: Casts and cv-qualifications Technical requirements What is a cast? Safety in the type system – cv-qualifications The C++ casts Your best friend (most of the time) – static_cast A sign something’s wrong – dynamic_cast Playing tricks with safety – const_cast “Believe me, compiler” – reinterpret_cast I know the bits are right – bit_cast Somewhat unrelated, but still – duration_cast The reviled one – the C cast Summary Part 2: Implicit Memory Management Techniques Chapter 4: Using Destructors Technical requirements On destructors: a short recap Managing resources Exception handling… or not? The RAII idiom RAII and C++’s special member functions Some pitfalls Destructors should not throw Know thy destruction order Standard resource management automation tools unique_ptr and shared_ptr lock_guard and scoped_lock stream objects vector and other containers Summary Chapter 5: Using Standard Smart Pointers Technical requirements The standard smart pointers On the exposition of intent through function signatures Type unique_ptr Handling objects Handling arrays Custom deleters make_unique Types shared_ptr and weak_ptr Usefulness and costs make_shared() What about weak_ptr? When to use raw pointers Summary Chapter 6: Writing Smart Pointers Technical requirements Ownership semantics Writing your own (naïve) unique_ptr Type signature Special member functions Pointer-like functions Writing your own (naïve) shared_ptr A few words on make_shared() Writing a policy-based duplicating pointer Detection through interfaces Detection through traits Detection through concepts Some not-so-smart yet useful smart pointers A non_null_ptr type An observer_ptr type Summary Part 3: Taking Control (of Memory Management Mechanisms) Chapter 7: Overloading Memory Allocation Operators Why would one overload allocation functions? Brief overview of the C language allocation functions Overview of the C++ allocation operators Global allocation operators Non-throwing versions of the allocation operators The most important operator new: placement new Member versions of the allocation operators Alignment-aware versions of the allocation operators Destroying delete Summary Chapter 8: Writing a Naïve Leak Detector Technical requirements The plan A first implementation (that almost works) The Accountant singleton class Implementing the new and new[] operators Implementing the delete and delete[] operators Visualizing it all Identifying (and fixing) the problems Revisiting our implementation (and lessons learned) Summary Chapter 9: Atypical Allocation Mechanisms Technical requirements Placement new and memory-mapped hardware Simplifying nothrow new usage Out-of-memory situations and new_handler Standard C++ and exotic memory A fictional shared memory API A handmade user code example A standard-looking user code equivalent Summary Chapter 10: Arena-Based Memory Management and Other Optimizations Technical requirements Arena-based memory management Specific example – size-based implementation Generalizing to SizeBasedArena When parameters change Chunked pools Summary Chapter 11: Deferred Reclamation Technical requirements What do we mean by deferred reclamation? Reclamation (without finalization) at the end of the program Reclamation and finalization at the end of the program Reclamation and finalization at the end of the scope Summary Part 4: Writing Generic Containers (and a Bit More) Chapter 12: Writing Generic Containers with Explicit Memory Management Technical requirements Writing your own vector alternative Representational choices for a container of contiguous elements The implementation of Vector Writing your own forward_list alternative Representational choices for a node-based container The implementation of ForwardList Better memory management A more efficient Vector Using low-level standard facilities Const or reference members and std::launder() Summary Chapter 13: Writing Generic Containers with Implicit Memory Management Technical requirements Why explicit memory management complicates our implementation Implicit memory management with a smart pointer Impact on the naïve Vector implementation Impact on the sophisticated Vector implementation Consequences of this redesign Generalizing to ForwardList ? Attempt - making each node responsible for its successor Attempt: making the head pointer responsible for the other nodes Summary Chapter 14: Writing Generic Containers with Allocator Support Technical requirements Why allocators? Traditional allocators Before C++11 Traditional allocators with contemporary standards Managing traditional allocator lifetime Irritants with traditional allocators Polymorphic memory resource allocators Nested allocators Allocators and data collection Upsides and costs Summary Chapter 15: Contemporary Issues Technical requirements Starting object lifetime without constructors Trivial relocation Type-aware allocation and deallocation functions Summary Annexure: Things You Should Know struct and class std::size_t The sizeof operator Assertions Undefined behavior Type traits The std::true_type and std::false_type traits The std::conditional trait Algorithms Functors (function objects) and lambdas Friends The decltype operator Perfect forwarding The singleton design pattern Instantiation at program startup Instantiation of the first call The std::exchange() function Index Other Books You May Enjoy