The document provides an introduction to Objective-C, including:
- Objective-C is layered on top of the C language and based on Smalltalk-80.
- It was designed in the 1980s and licensed by NeXT in 1988.
- Today it is the native language for developing Mac OS X and iOS apps.
- The document demonstrates declaring a class, implementing a class, testing the class, and compiling and running a simple Objective-C program.
- It also covers topics like memory management, object lifecycles, and the differences between static, stack and heap memory.
Dynamic memory allocation allows programs to request memory from the operating system at runtime. This memory is allocated on the heap. Functions like malloc(), calloc(), and realloc() are used to allocate and reallocate dynamic memory, while free() releases it. Malloc allocates a single block of uninitialized memory. Calloc allocates multiple blocks of initialized (zeroed) memory. Realloc changes the size of previously allocated memory. Proper use of these functions avoids memory leaks.
Pythran: Static compiler for high performance by Mehdi Amini PyData SV 2014PyData
Pythran is a an ahead of time compiler that turns modules written in a large subset of Python into C++ meta-programs that can be compiled into efficient native modules. It targets mainly compute intensive part of the code, hence it comes as no surprise that it focuses on scientific applications that makes extensive use of Numpy. Under the hood, Pythran inter-procedurally analyses the program and performs high level optimizations and parallel code generation. Parallelism can be found implicitly in Python intrinsics or Numpy operations, or explicitly specified by the programmer using OpenMP directives directly in the Python source code. Either way, the input code remains fully compatible with the Python interpreter. While the idea is similar to Parakeet or Numba, the approach differs significantly: the code generation is not performed at runtime but offline. Pythran generates C++11 heavily templated code that makes use of the NT2 meta-programming library and relies on any standard-compliant compiler to generate the binary code. We propose to walk through some examples and benchmarks, exposing the current state of what Pythran provides as well as the limit of the approach.
Sheng Li completed work in the Spacecraft Relative Motion Control Lab over the summer of 2016. This included developing multiple object tracking for the motion capture system, building a simple estimator for the model predictive control (MPC) controller in Simulink, and gaining an understanding of the robot controller codes. Key achievements were realizing multiple object tracking by modifying variable dimensions, developing a simple estimator to account for camera measurement errors, and learning how to control the robot motion with existing codes.
Basic concept of Deep Learning with explaining its structure and backpropagation method and understanding autograd in PyTorch. (+ Data parallism in PyTorch)
Objective-C Crash Course for Web DevelopersJoris Verbogt
These are the slides of my SXSW 2010 Objective-C Crash Course for Web Developers.
The code samples (and the keynote document) can also be downloaded from http://workshop.verbogt.nl/
A minimal collection of most wanted and widely accepted idioms and coding conventions for C++ development presented with examples and explanations. The lecture targets performance oriented codes so emphasis is on performance-friendly techiques.
Topics covered:
1) Design issues: idioms and best practices
- Resource Aquisition Is Initialization (RAII)
- Ownership semantics and smart pointers
- Header files: dependencies and decoupling
2) Objects Construction/Destruction/Copying
- Designing constructors
- Rule Of Three
- Transactional programming
3) Namespaces
- ADL/Koenig Lookup
4) Static analyzers
The Evolution of Async-Programming on .NET Platform (.Net China, C#)jeffz
This document discusses the evolution of asynchronous programming on the .NET platform. It covers early approaches using Begin/End methods and event-based patterns in .NET 1.0. It then discusses improvements with yield in .NET 2.0/C# 2.0 and async workflows in F# for .NET 3.0. It also covers the Reactive Framework for .NET 4.0 which treats asynchronous computations as push-based collections. Finally, it discusses potential future improvements in C# vNext.
Dynamic memory allocation allows programs to request memory from the operating system at runtime. This memory is allocated on the heap. Functions like malloc(), calloc(), and realloc() are used to allocate and reallocate dynamic memory, while free() releases it. Malloc allocates a single block of uninitialized memory. Calloc allocates multiple blocks of initialized (zeroed) memory. Realloc changes the size of previously allocated memory. Proper use of these functions avoids memory leaks.
Pythran: Static compiler for high performance by Mehdi Amini PyData SV 2014PyData
Pythran is a an ahead of time compiler that turns modules written in a large subset of Python into C++ meta-programs that can be compiled into efficient native modules. It targets mainly compute intensive part of the code, hence it comes as no surprise that it focuses on scientific applications that makes extensive use of Numpy. Under the hood, Pythran inter-procedurally analyses the program and performs high level optimizations and parallel code generation. Parallelism can be found implicitly in Python intrinsics or Numpy operations, or explicitly specified by the programmer using OpenMP directives directly in the Python source code. Either way, the input code remains fully compatible with the Python interpreter. While the idea is similar to Parakeet or Numba, the approach differs significantly: the code generation is not performed at runtime but offline. Pythran generates C++11 heavily templated code that makes use of the NT2 meta-programming library and relies on any standard-compliant compiler to generate the binary code. We propose to walk through some examples and benchmarks, exposing the current state of what Pythran provides as well as the limit of the approach.
Sheng Li completed work in the Spacecraft Relative Motion Control Lab over the summer of 2016. This included developing multiple object tracking for the motion capture system, building a simple estimator for the model predictive control (MPC) controller in Simulink, and gaining an understanding of the robot controller codes. Key achievements were realizing multiple object tracking by modifying variable dimensions, developing a simple estimator to account for camera measurement errors, and learning how to control the robot motion with existing codes.
Basic concept of Deep Learning with explaining its structure and backpropagation method and understanding autograd in PyTorch. (+ Data parallism in PyTorch)
Objective-C Crash Course for Web DevelopersJoris Verbogt
These are the slides of my SXSW 2010 Objective-C Crash Course for Web Developers.
The code samples (and the keynote document) can also be downloaded from http://workshop.verbogt.nl/
A minimal collection of most wanted and widely accepted idioms and coding conventions for C++ development presented with examples and explanations. The lecture targets performance oriented codes so emphasis is on performance-friendly techiques.
Topics covered:
1) Design issues: idioms and best practices
- Resource Aquisition Is Initialization (RAII)
- Ownership semantics and smart pointers
- Header files: dependencies and decoupling
2) Objects Construction/Destruction/Copying
- Designing constructors
- Rule Of Three
- Transactional programming
3) Namespaces
- ADL/Koenig Lookup
4) Static analyzers
The Evolution of Async-Programming on .NET Platform (.Net China, C#)jeffz
This document discusses the evolution of asynchronous programming on the .NET platform. It covers early approaches using Begin/End methods and event-based patterns in .NET 1.0. It then discusses improvements with yield in .NET 2.0/C# 2.0 and async workflows in F# for .NET 3.0. It also covers the Reactive Framework for .NET 4.0 which treats asynchronous computations as push-based collections. Finally, it discusses potential future improvements in C# vNext.
"О некоторых особенностях Objective-C++" Влад Михайленко (Maps.Me)AvitoTech
В своём докладе Влад будет говорить об использовании STL, управлении памятью, как работает ARC и C++, лямбды и блоки. И самое главное: где и как можно «выстрелить себе в ногу».
This document provides an overview of the Ontopia topic maps software project. It discusses the history and architecture of the project. The core consists of an engine that provides an API for working with topic maps and supports various backends for storage such as in-memory, RDBMS, and remote. Other modules include tools for importing, navigating, classifying text, visualizing, and editing topic maps. The query language tolog is introduced as the recommended way to interact with topic map data. Common APIs, persistence options, and the event system are summarized.
LLVM is currently finalizing the migration from typed pointers (i32*) to opaque pointers (ptr) -- the likely largest intermediate representation change in LLVM's history. In this talk, we'll discuss the motivations for the change, how it will affect developers working on/with LLVM in practice, and why this migration took such a long time. We'll also briefly cover possible future IR changes based on opaque pointers.
PyTorch crash course: Introduction to PyTorch deep learning framework and step by step guide to configuring PyCharm for using a remote server for implementing deep learning, plus a summary of Linux's most relevant commands.
The Evolution of Async-Programming on .NET Platform (TUP, Full)jeffz
The document discusses the evolution of asynchronous programming on the .NET platform. It covers:
1. .NET 1.0 introduced basic asynchronous patterns using Begin/End methods and event-based callbacks, but they broke code locality and were difficult to use.
2. .NET 2.0 and C# 2.0 introduced "yield return" which allowed iterating over asynchronous operations in a synchronous style and improved code locality.
3. .NET 3.0 and F# further advanced this by treating asynchronous operations as first-class functions, allowing easier composition and exception handling of multiple asynchronous tasks.
4. Future versions aim to continue improving asynchronous programming models and libraries to better support cloud, web and mobile
Swift is proposed as a next-generation platform for TensorFlow that could provide benefits over Python like improved performance, type safety, and enabling automatic differentiation at compile time. However, Python currently dominates the machine learning ecosystem. Swift and Python are intended to have a complementary relationship, with each suited to different use cases. Examples show comparable MNIST implementations in both Swift and Python for TensorFlow.
SciPy and NumPy are Python packages that provide scientific computing capabilities. NumPy provides multidimensional array objects and fast linear algebra functions. SciPy builds on NumPy and adds modules for optimization, integration, signal and image processing, and more. Together, NumPy and SciPy give Python powerful data analysis and visualization capabilities. The community contributes to both projects to expand their functionality. Memory mapped arrays in NumPy allow working with large datasets that exceed system memory.
This document discusses structured data types in C++, including arrays and classes/structs. It provides examples of declaring and using arrays, such as storing user input in an array, traversing it using a for loop, and passing arrays to functions. Classes and structs allow storing different data types together and must be defined before use. Overall, the document introduces some basic concepts about structured data types for organizing and manipulating data in C++ programs.
This document discusses techniques for optimizing JavaScript execution through just-in-time compilation (JIT). It describes how a basic JIT works by generating optimized machine code for common cases like integer math. It also covers challenges like handling different object shapes through inline caching of property accesses and generating polymorphic code stubs. The goal of these techniques is to make JavaScript execution faster while avoiding noticeable compilation pauses.
Egor Bogatov - .NET Core intrinsics and other micro-optimizationsEgor Bogatov
The document discusses various micro-optimizations and techniques for optimizing .NET code including using Span over Substring, avoiding allocations by using stackalloc or ArrayPool, eliminating bounds checks, using intrinsics and SIMD, and examples of optimizing specific algorithms like reversing an array. It covers potential pitfalls like type casts not being free and differences between runtimes. Intrinsics and SIMD can provide significant performance improvements over naive implementations by leveraging CPU instructions.
NumPy is a Python library used for working with multidimensional arrays and matrices for scientific computing. It allows fast operations on arrays through optimized C code and is the foundation of the Python scientific computing stack. NumPy arrays can be created in many ways and support operations like indexing, slicing, broadcasting, and universal functions. NumPy provides many useful features for linear algebra, Fourier transforms, random number generation and more.
This document provides an overview of the Python programming language. It discusses Python's history and evolution, its key features like being object-oriented, open source, portable, having dynamic typing and built-in types/tools. It also covers Python's use for numeric processing with libraries like NumPy and SciPy. The document explains how to use Python interactively from the command line and as scripts. It describes Python's basic data types like integers, floats, strings, lists, tuples and dictionaries as well as common operations on these types.
Computer Vision using Ruby and libJIT - RubyConf 2009Jan Wedekind
Ruby originated in Japan, the country which is world-leading in robotic research. It suggests itself to put the two together and to start using Ruby as a language to program robots. However at the moment the performance of available Ruby interpreters is not sufficient. It is hard to achieve performance comparable to compiled C++-code since manipulation of Ruby-integers and Ruby-arrays requires frequent bounds-checking. It can be shown that universal bounds-check elimination is actually impossible.
The release of TensorFlow 2.0 comes with a significant number of improvements over its 1.x version, all with a focus on ease of usability and a better user experience. We will give an overview of what TensorFlow 2.0 is and discuss how to get started building models from scratch using TensorFlow 2.0’s high-level api, Keras. We will walk through an example step-by-step in Python of how to build an image classifier. We will then showcase how to leverage a transfer learning to make building a model even easier! With transfer learning, we can leverage other pretrained models such as ImageNet to drastically speed up the training time of our model. TensorFlow 2.0 makes this incredibly simple to do.
The document discusses specializing data structures in Scala for performance. It presents a specialized queue (CQueue) that can be implemented for specific types like Int to avoid boxing overhead. A CQueueFactory is used to instantiate the appropriate implementation based on the type. The implementations extend traits to implement the queue interface while delegating to specialized underlying collections like IntPriorityQueue. This allows creating specialized queues for Ints that have better performance than the generic implementation.
Seeing with Python presented at PyCon AU 2014Mark Rees
This document discusses the history and current state of computer vision. It begins with definitions of computer vision from the 1980s, focusing on machine vision and automatically analyzing images. It then provides a 2014 definition that emphasizes duplicating human vision abilities through electronic image perception and understanding using models from various fields. The document notes computer vision involves more than just image capture, including image processing, algorithm development, and display control. It also lists and briefly describes several popular Python libraries for computer vision tasks, such as PIL, Scipy ndimage, Mahotas, PCV, SimpleCV, and OpenCV. It concludes with resources for learning more about computer vision and Python.
The document discusses techniques that JavaScript engines use to optimize performance, including:
- Just-in-time compilation to generate optimized native machine code from JavaScript bytecode. This includes tracing optimizations and register allocation.
- Inline caching to speed up property lookups by caching the results of previous lookups.
- Type inference to determine types statically to avoid slow dynamic checks.
- Built-in optimizations in engines like V8 such as hidden classes, precise garbage collection, and Crankshaft, its optimizing compiler.
This talk discusses various issues of low-level PHP performance, such as: When is it more efficient to use arrays or objects? What causes catastrophic garbage collection? Does adding type annotations make PHP faster or slower?
I will answer these types of question with a (shallow) dive into PHP internals, touching on various topics like value representation, bytecode optimization and GC.
1. The document describes the implementation of a K-means clustering algorithm from scratch in Python. It includes data normalization, K-means++ initialization, and evaluation using the Silhouette method.
2. Various techniques are tested to improve the algorithm, including normalization to handle differently scaled features, and K-means++ initialization to avoid poor initial centroid locations.
3. The algorithm outputs the centroid locations, a plot of Silhouette scores against K values, and a 3D plot visualizing the clustered data points and centroids.
The document provides an introduction to Objective-C, including background information on its origins and current usage. It discusses key Objective-C concepts like classes, methods, memory management, and the differences between static, stack and heap memory. Code examples are provided to demonstrate how to declare classes, instantiate objects, call methods, and handle memory allocation and release of objects.
Dynamic memory allocation allows programs to request additional memory at runtime as needed, rather than having a fixed amount allocated at compile time. The malloc function allocates memory on the heap and returns a pointer to it. This memory must later be freed using free to avoid memory leaks. Calloc initializes allocated memory to zero, while realloc changes the size of previously allocated memory. C supports dynamic memory allocation through library functions like malloc, calloc, free and realloc.
"О некоторых особенностях Objective-C++" Влад Михайленко (Maps.Me)AvitoTech
В своём докладе Влад будет говорить об использовании STL, управлении памятью, как работает ARC и C++, лямбды и блоки. И самое главное: где и как можно «выстрелить себе в ногу».
This document provides an overview of the Ontopia topic maps software project. It discusses the history and architecture of the project. The core consists of an engine that provides an API for working with topic maps and supports various backends for storage such as in-memory, RDBMS, and remote. Other modules include tools for importing, navigating, classifying text, visualizing, and editing topic maps. The query language tolog is introduced as the recommended way to interact with topic map data. Common APIs, persistence options, and the event system are summarized.
LLVM is currently finalizing the migration from typed pointers (i32*) to opaque pointers (ptr) -- the likely largest intermediate representation change in LLVM's history. In this talk, we'll discuss the motivations for the change, how it will affect developers working on/with LLVM in practice, and why this migration took such a long time. We'll also briefly cover possible future IR changes based on opaque pointers.
PyTorch crash course: Introduction to PyTorch deep learning framework and step by step guide to configuring PyCharm for using a remote server for implementing deep learning, plus a summary of Linux's most relevant commands.
The Evolution of Async-Programming on .NET Platform (TUP, Full)jeffz
The document discusses the evolution of asynchronous programming on the .NET platform. It covers:
1. .NET 1.0 introduced basic asynchronous patterns using Begin/End methods and event-based callbacks, but they broke code locality and were difficult to use.
2. .NET 2.0 and C# 2.0 introduced "yield return" which allowed iterating over asynchronous operations in a synchronous style and improved code locality.
3. .NET 3.0 and F# further advanced this by treating asynchronous operations as first-class functions, allowing easier composition and exception handling of multiple asynchronous tasks.
4. Future versions aim to continue improving asynchronous programming models and libraries to better support cloud, web and mobile
Swift is proposed as a next-generation platform for TensorFlow that could provide benefits over Python like improved performance, type safety, and enabling automatic differentiation at compile time. However, Python currently dominates the machine learning ecosystem. Swift and Python are intended to have a complementary relationship, with each suited to different use cases. Examples show comparable MNIST implementations in both Swift and Python for TensorFlow.
SciPy and NumPy are Python packages that provide scientific computing capabilities. NumPy provides multidimensional array objects and fast linear algebra functions. SciPy builds on NumPy and adds modules for optimization, integration, signal and image processing, and more. Together, NumPy and SciPy give Python powerful data analysis and visualization capabilities. The community contributes to both projects to expand their functionality. Memory mapped arrays in NumPy allow working with large datasets that exceed system memory.
This document discusses structured data types in C++, including arrays and classes/structs. It provides examples of declaring and using arrays, such as storing user input in an array, traversing it using a for loop, and passing arrays to functions. Classes and structs allow storing different data types together and must be defined before use. Overall, the document introduces some basic concepts about structured data types for organizing and manipulating data in C++ programs.
This document discusses techniques for optimizing JavaScript execution through just-in-time compilation (JIT). It describes how a basic JIT works by generating optimized machine code for common cases like integer math. It also covers challenges like handling different object shapes through inline caching of property accesses and generating polymorphic code stubs. The goal of these techniques is to make JavaScript execution faster while avoiding noticeable compilation pauses.
Egor Bogatov - .NET Core intrinsics and other micro-optimizationsEgor Bogatov
The document discusses various micro-optimizations and techniques for optimizing .NET code including using Span over Substring, avoiding allocations by using stackalloc or ArrayPool, eliminating bounds checks, using intrinsics and SIMD, and examples of optimizing specific algorithms like reversing an array. It covers potential pitfalls like type casts not being free and differences between runtimes. Intrinsics and SIMD can provide significant performance improvements over naive implementations by leveraging CPU instructions.
NumPy is a Python library used for working with multidimensional arrays and matrices for scientific computing. It allows fast operations on arrays through optimized C code and is the foundation of the Python scientific computing stack. NumPy arrays can be created in many ways and support operations like indexing, slicing, broadcasting, and universal functions. NumPy provides many useful features for linear algebra, Fourier transforms, random number generation and more.
This document provides an overview of the Python programming language. It discusses Python's history and evolution, its key features like being object-oriented, open source, portable, having dynamic typing and built-in types/tools. It also covers Python's use for numeric processing with libraries like NumPy and SciPy. The document explains how to use Python interactively from the command line and as scripts. It describes Python's basic data types like integers, floats, strings, lists, tuples and dictionaries as well as common operations on these types.
Computer Vision using Ruby and libJIT - RubyConf 2009Jan Wedekind
Ruby originated in Japan, the country which is world-leading in robotic research. It suggests itself to put the two together and to start using Ruby as a language to program robots. However at the moment the performance of available Ruby interpreters is not sufficient. It is hard to achieve performance comparable to compiled C++-code since manipulation of Ruby-integers and Ruby-arrays requires frequent bounds-checking. It can be shown that universal bounds-check elimination is actually impossible.
The release of TensorFlow 2.0 comes with a significant number of improvements over its 1.x version, all with a focus on ease of usability and a better user experience. We will give an overview of what TensorFlow 2.0 is and discuss how to get started building models from scratch using TensorFlow 2.0’s high-level api, Keras. We will walk through an example step-by-step in Python of how to build an image classifier. We will then showcase how to leverage a transfer learning to make building a model even easier! With transfer learning, we can leverage other pretrained models such as ImageNet to drastically speed up the training time of our model. TensorFlow 2.0 makes this incredibly simple to do.
The document discusses specializing data structures in Scala for performance. It presents a specialized queue (CQueue) that can be implemented for specific types like Int to avoid boxing overhead. A CQueueFactory is used to instantiate the appropriate implementation based on the type. The implementations extend traits to implement the queue interface while delegating to specialized underlying collections like IntPriorityQueue. This allows creating specialized queues for Ints that have better performance than the generic implementation.
Seeing with Python presented at PyCon AU 2014Mark Rees
This document discusses the history and current state of computer vision. It begins with definitions of computer vision from the 1980s, focusing on machine vision and automatically analyzing images. It then provides a 2014 definition that emphasizes duplicating human vision abilities through electronic image perception and understanding using models from various fields. The document notes computer vision involves more than just image capture, including image processing, algorithm development, and display control. It also lists and briefly describes several popular Python libraries for computer vision tasks, such as PIL, Scipy ndimage, Mahotas, PCV, SimpleCV, and OpenCV. It concludes with resources for learning more about computer vision and Python.
The document discusses techniques that JavaScript engines use to optimize performance, including:
- Just-in-time compilation to generate optimized native machine code from JavaScript bytecode. This includes tracing optimizations and register allocation.
- Inline caching to speed up property lookups by caching the results of previous lookups.
- Type inference to determine types statically to avoid slow dynamic checks.
- Built-in optimizations in engines like V8 such as hidden classes, precise garbage collection, and Crankshaft, its optimizing compiler.
This talk discusses various issues of low-level PHP performance, such as: When is it more efficient to use arrays or objects? What causes catastrophic garbage collection? Does adding type annotations make PHP faster or slower?
I will answer these types of question with a (shallow) dive into PHP internals, touching on various topics like value representation, bytecode optimization and GC.
1. The document describes the implementation of a K-means clustering algorithm from scratch in Python. It includes data normalization, K-means++ initialization, and evaluation using the Silhouette method.
2. Various techniques are tested to improve the algorithm, including normalization to handle differently scaled features, and K-means++ initialization to avoid poor initial centroid locations.
3. The algorithm outputs the centroid locations, a plot of Silhouette scores against K values, and a 3D plot visualizing the clustered data points and centroids.
The document provides an introduction to Objective-C, including background information on its origins and current usage. It discusses key Objective-C concepts like classes, methods, memory management, and the differences between static, stack and heap memory. Code examples are provided to demonstrate how to declare classes, instantiate objects, call methods, and handle memory allocation and release of objects.
Dynamic memory allocation allows programs to request additional memory at runtime as needed, rather than having a fixed amount allocated at compile time. The malloc function allocates memory on the heap and returns a pointer to it. This memory must later be freed using free to avoid memory leaks. Calloc initializes allocated memory to zero, while realloc changes the size of previously allocated memory. C supports dynamic memory allocation through library functions like malloc, calloc, free and realloc.
The document provides an introduction to memory management in C. It discusses that memory can be allocated in C either by declaring variables, which allocates space on the stack, or by explicitly requesting space from C using functions like malloc(), which allocates space on the heap. The stack follows LIFO order and releases space automatically when the program finishes, while the heap requires manual memory management using free(). Functions like malloc() allocate raw memory on the heap and return a pointer to it, while calloc() allocates initialized memory in blocks. The document also discusses stack overflow and the different memory sections in RAM like text, data, BSS, and heap.
Programs are complete in best of my knowledge with zero compilation error in IDE Bloodshed Dev-C++. These can be easily portable to any versions of Visual Studio or Qt. If you need any guidance please let me know via comments and Always Enjoy Programming.
This document provides an overview of functions with heap and stack memory in 3 parts. It begins by defining the stack and heap, explaining that the stack uses LIFO data structure for allocation while the heap uses a binary tree. It then discusses memory allocation on the stack versus the heap, noting advantages of each like faster access for stack vs ability to access variables globally with heap. It concludes by summarizing potential problems with each method like stack overflow versus memory fragmentation on the heap.
The document discusses Ruochun Tzeng's midterm presentation on OpenMP. It covers OpenMP's shared memory model and fork-join execution model. It provides examples of using OpenMP for data and task parallelism. It also discusses using OpenMP for irregular problems and the task construct. Finally, it summarizes Ruochun's attempts to parallelize four algorithms using OpenMP and the performance results.
This presentation comes with many additional notes (pdf): http://de.slideshare.net/nicolayludwig/2-collections-algorithms-38612937
- Arrays revisited
- Value and Reference Semantics of Elements
- A Way to categorize Collections
- Indexed Collections
-- Lists
-- Basic Features and Examples
-- Size and Capacity
This document provides an overview of memory management concepts in Java and C++, including pointers, the heap, stack, activation records, classes and objects. It discusses how objects are allocated in memory in both languages, with objects in Java being referenced by pointers on the stack and allocated on the heap, while in C++ objects can be allocated on the stack or heap. The document also covers issues like memory leaks in C++ if objects are not deleted from the heap, and garbage collection handling object deletion in Java. Methods and calling conventions are compared between the two languages.
The document discusses iPhone app development using Objective-C. It covers the basics of getting started, including what is needed to begin like a Mac, Xcode, and an iPhone. It then explains key Objective-C concepts like classes, methods, and memory management using retain counts. The document also discusses unit testing iOS apps using OCUnit and some Xcode tips. It emphasizes testing first and concludes by noting the market demands more apps and there is room for improvement.
Notes about moving from python to c++ py contw 2020Yung-Yu Chen
The document discusses moving from Python to C++. It notes that Python is commonly used for application development due to its ease of use, while C++ is used for high-performance computing kernels due to better performance. It recommends binding Python and C++ together, using C++ for performance critical parts and Python for user interfaces and scripting. Pybind11 is identified as a good tool for binding Python and C++ that provides modern C++ features and is easy to use.
This document provides an overview of mobile development and the iOS ecosystem. It discusses that mobile apps require UI optimization and a mission statement. It also covers Xcode, Objective-C, memory management, UIKit, MapKit, and annotations for displaying locations on maps. The document recommends designing mobile apps differently than desktop apps and following Apple's human interface guidelines.
This document provides an overview of C++ development environments, basic C++ syntax like classes and pointers, and key concepts like memory management and object oriented programming. It discusses compiling C++ code with g++, using makefiles, preprocessor directives, classes, procedural programming, pointers, memory allocation, problems like dangling pointers and memory leaks, and canonical class forms.
The document discusses dynamic memory allocation in C using functions like malloc(), calloc(), realloc() and free(). It explains that malloc() allocates memory without initializing it, calloc() allocates memory and initializes it to zero, and realloc() resizes previously allocated memory. Examples are provided to demonstrate allocating memory for arrays, 2D arrays, structures and resizing memory. It emphasizes the importance of freeing unneeded memory to avoid memory leaks.
The Android Native Development Kit (NDK) allows developers to write and embed native code like C/C++ in Android applications. It provides toolchains and headers to allow compilation of native code into libraries that can be called from Java code using the Java Native Interface. The NDK benefits applications requiring intensive CPU operations, games, or porting existing C/C++ code to Android. However, native code also increases complexity, so the NDK should only be used when truly needed rather than for preference of language. Sample projects demonstrate using the NDK to incorporate native code for tasks like threading and improving performance of algorithms.
This document discusses different approaches for profiling Java applications without using third-party tools. It begins by explaining the benefits of a do-it-yourself approach such as avoiding reliability and compliance concerns with tools. Various profiling types are then covered, including CPU profiling using wall clock time and calls, sampling, and memory profiling using JVM options. Bytecode manipulation is also presented as a method using ASM to add profiling code without changing sources. The document emphasizes learning the Java Virtual Machine and using its built-in capabilities for profiling purposes.
Being functional in PHP (PHPDay Italy 2016)David de Boer
Functional programming, though far from new, has gained much traction recently. Functional programming characteristics have started to appear in the PHP world, too. Microframeworks such as Silex and Slim, middleware architectures such as Stack and even standards such as PSR-7 rely on concepts such as lambdas, referential transparency and immutability, all of which come from functional programming. I’ll give you a crash course in Erlang, a pragmatic functional language to make you feel familiar with the functional paradigm. By comparing code samples between Erlang and PHP, you’ll find out how you can employ functional programming in your PHP applications where appropriate. You’ll see that functional programming is nothing to be scared of. On the contrary, understanding its concepts broadens your programming horizon and provides you with valuable solutions to your problems.
The document provides an introduction to C++ programming. It outlines topics that will be covered, including basic syntax, compiling programs, passing arguments, dynamic memory allocation, and object-oriented programming. It recommends several useful books and web resources for learning C++ and offers a live coding demonstration of a simple image class to illustrate C++ concepts. The overall tone is informative but acknowledges that C++ is complex and learning requires practice.
Brief introduction to the c programming languageKumar Gaurav
The document provides an introduction to the C programming language. It discusses that C was created in the 1970s and was influenced by other languages. It describes standardization of C in 1989 and later updates. It also covers basic elements of a C program like main functions, header files, simple programs, passing command line arguments, and pointers. The document uses examples to explain concepts like arrays, macros, and conditional compilation using the preprocessor.
This document provides a summary of Taro Matsuzawa's career and activities from 1981 to 2011. It notes that he was involved with various computer-related clubs and organizations in Japan, including English language societies and Linux communities. It also discusses his work on open source projects like Mozilla and Pantomime, an open source email library for iOS.
Module 19 tracking emails and investigating email crimessagaroceanic11
The document discusses the benefits of exercise for mental health. Regular physical activity can help reduce anxiety and depression and improve mood and cognitive functioning. Exercising for at least 30 minutes three times per week is recommended to see these mental health benefits.
The document discusses the benefits of exercise for both physical and mental health. Regular exercise can improve cardiovascular health, reduce stress and anxiety, boost mood, and reduce the risk of diseases. It recommends that adults get at least 150 minutes of moderate exercise or 75 minutes of vigorous exercise per week to gain these benefits.
The document discusses the benefits of exercise for mental health. Regular physical activity can help reduce anxiety and depression and improve mood and cognitive functioning. Exercise has also been shown to increase gray matter volume in the brain and reduce risks for conditions like Alzheimer's and dementia.
The document discusses the benefits of exercise for mental health. Regular physical activity can help reduce anxiety and depression and improve mood and cognitive functioning. Exercise has also been shown to boost self-esteem and can serve as a healthy way to manage stress.
The document discusses the benefits of exercise for mental health. Regular physical activity can help reduce anxiety and depression and improve mood and cognitive functioning. Exercise causes chemical changes in the brain that may help protect against mental illness and improve symptoms.
Module 01 computer forensics in todays worldsagaroceanic11
The document discusses the benefits of exercise for mental health. Regular physical activity can help reduce anxiety and depression and improve mood and cognitive function. Exercise causes chemical changes in the brain that may help protect against mental illness and improve symptoms.
Virtualization provides abstraction between hardware and software. It allows multiple virtual machines to run on a single physical machine, sharing resources. There are two approaches - hosted virtualization runs on a standard OS, while hypervisor architecture installs directly on hardware for better efficiency. VMware offers virtualization software for data centers, desktops, and mobile devices to optimize resource use across hardware, storage, and networks. Standards like OVF and VMDK help define virtual machine packaging and disk formats.
Virtualization technologies allow servers to be consolidated onto fewer physical servers for improved efficiency. IBM's PowerVM allows one physical server to be divided into multiple logical partitions (LPARs), with each LPAR able to run its own operating system. Key PowerVM technologies include micro-partitioning which divides physical CPUs among LPARs, dynamic LPARs which moves resources between active partitions, and virtual I/O servers which allow partitions to share physical network and storage adapters. These technologies improve utilization, flexibility, and availability compared to using separate physical servers.
Virtualization has its origins in mainframe computing from the 1960s. It allows a single physical server to run multiple virtual machines, each with its own operating system and applications. This addresses challenges from the 1990s and 2000s as companies had many single-purpose physical servers with low utilization rates, high costs, and management complexity. Virtualization software introduces a hypervisor layer that partitions resources and isolates virtual machines so multiple operating systems can run independently on the same physical hardware. Today virtualization delivers benefits like server consolidation, high availability, disaster recovery, and rapid provisioning to improve efficiency and reduce costs.
1. Server virtualization involves dividing the resources of a physical server, such as CPU, memory and storage, into multiple isolated virtual machines to run multiple operating systems and applications.
2. Early virtualization technology from the 1960s allowed identical "copies" of hardware to run on IBM mainframes, enabling time-sharing of computing resources.
3. Modern server virtualization provides increased hardware utilization, consolidation of servers, mobility of workloads, business continuity, and simplified development/testing environments.
The document discusses key concepts and processes related to service operation, including event management, incident management, request fulfillment, and problem management. Event management monitors events through the IT infrastructure to detect exceptions and ensure normal operation. Incident management aims to restore service as quickly as possible when incidents occur. Request fulfillment handles standard user requests. Problem management seeks to prevent problems and reduce the impact of incidents that do occur.
This document provides an overview of service transition concepts and processes including:
- The V model for service transition
- Configuration items and the configuration management system
- Knowledge management concepts
- Change management, service asset and configuration management, and release and deployment management processes
- Key roles, activities, and objectives for managing changes to services in a controlled manner throughout the service lifecycle
The document discusses key concepts in service design and management including the four Ps (products, partners, people, processes), service design packages, and aspects of service design like services, management systems, architectures, processes, and metrics. It then provides more detailed information on specific service management processes like service catalog management, service level management, and their goals, activities, roles, and challenges. The overall document provides an overview of service design and several important service management processes.
This document provides an overview of ITIL service strategy. It discusses key concepts of utility, warranty, service providers, delivery models, and service models. It also summarizes the processes of service portfolio management, demand management, and financial management which are part of developing an effective service strategy.
The document discusses the key concepts and processes in the Information Technology Infrastructure Library (ITIL) framework. ITIL describes best practices for IT service management and is broken down into five core publications: Service Strategy, Service Design, Service Transition, Service Operation, and Continual Service Improvement. Each publication focuses on a different stage of the service lifecycle to help align IT services with business needs and ensure quality service delivery.
This document provides an introduction to ITIL v.3 Foundation. It outlines the learning objectives which are to understand the ITIL service management lifecycle and its five core practices. It describes how ITIL has evolved over time to become best practice for IT service management. Key concepts discussed include services, service providers, service management, service owners, processes, and roles like process owners. The RACI model for defining roles and responsibilities is also introduced.
Visual Studio 2008 improves developer productivity, collaboration across the lifecycle, and employs the latest technologies. It rejuvenates developers with LINQ for data and support for service-oriented architecture. Visual Studio 2008 also simplifies mobility, provides better deployment with client services, and enhances quality. The release delivers full lifecycle management with real-time project reporting for a more predictable, visible, and controlled development process.
This document provides an overview of the history and development of the Visual Basic programming language. It discusses how Visual Basic originated from the BASIC language in the 1960s and was later adapted for microcomputers by Bill Gates and Paul Allen in the 1970s. Every version of Basic since has been based on their early work. Visual Basic was then introduced by Microsoft in 1991 and continued to be updated with new features and capabilities in subsequent versions like Visual Basic 3.0, 4.0, 5.0 and 6.0. The document also defines some key Visual Basic concepts and terms.
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor IvaniukFwdays
At this talk we will discuss DDoS protection tools and best practices, discuss network architectures and what AWS has to offer. Also, we will look into one of the largest DDoS attacks on Ukrainian infrastructure that happened in February 2022. We'll see, what techniques helped to keep the web resources available for Ukrainians and how AWS improved DDoS protection for all customers based on Ukraine experience
AppSec PNW: Android and iOS Application Security with MobSFAjin Abraham
Mobile Security Framework - MobSF is a free and open source automated mobile application security testing environment designed to help security engineers, researchers, developers, and penetration testers to identify security vulnerabilities, malicious behaviours and privacy concerns in mobile applications using static and dynamic analysis. It supports all the popular mobile application binaries and source code formats built for Android and iOS devices. In addition to automated security assessment, it also offers an interactive testing environment to build and execute scenario based test/fuzz cases against the application.
This talk covers:
Using MobSF for static analysis of mobile applications.
Interactive dynamic security assessment of Android and iOS applications.
Solving Mobile app CTF challenges.
Reverse engineering and runtime analysis of Mobile malware.
How to shift left and integrate MobSF/mobsfscan SAST and DAST in your build pipeline.
Driving Business Innovation: Latest Generative AI Advancements & Success StorySafe Software
Are you ready to revolutionize how you handle data? Join us for a webinar where we’ll bring you up to speed with the latest advancements in Generative AI technology and discover how leveraging FME with tools from giants like Google Gemini, Amazon, and Microsoft OpenAI can supercharge your workflow efficiency.
During the hour, we’ll take you through:
Guest Speaker Segment with Hannah Barrington: Dive into the world of dynamic real estate marketing with Hannah, the Marketing Manager at Workspace Group. Hear firsthand how their team generates engaging descriptions for thousands of office units by integrating diverse data sources—from PDF floorplans to web pages—using FME transformers, like OpenAIVisionConnector and AnthropicVisionConnector. This use case will show you how GenAI can streamline content creation for marketing across the board.
Ollama Use Case: Learn how Scenario Specialist Dmitri Bagh has utilized Ollama within FME to input data, create custom models, and enhance security protocols. This segment will include demos to illustrate the full capabilities of FME in AI-driven processes.
Custom AI Models: Discover how to leverage FME to build personalized AI models using your data. Whether it’s populating a model with local data for added security or integrating public AI tools, find out how FME facilitates a versatile and secure approach to AI.
We’ll wrap up with a live Q&A session where you can engage with our experts on your specific use cases, and learn more about optimizing your data workflows with AI.
This webinar is ideal for professionals seeking to harness the power of AI within their data management systems while ensuring high levels of customization and security. Whether you're a novice or an expert, gain actionable insights and strategies to elevate your data processes. Join us to see how FME and AI can revolutionize how you work with data!
How information systems are built or acquired puts information, which is what they should be about, in a secondary place. Our language adapted accordingly, and we no longer talk about information systems but applications. Applications evolved in a way to break data into diverse fragments, tightly coupled with applications and expensive to integrate. The result is technical debt, which is re-paid by taking even bigger "loans", resulting in an ever-increasing technical debt. Software engineering and procurement practices work in sync with market forces to maintain this trend. This talk demonstrates how natural this situation is. The question is: can something be done to reverse the trend?
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...Alex Pruden
Folding is a recent technique for building efficient recursive SNARKs. Several elegant folding protocols have been proposed, such as Nova, Supernova, Hypernova, Protostar, and others. However, all of them rely on an additively homomorphic commitment scheme based on discrete log, and are therefore not post-quantum secure. In this work we present LatticeFold, the first lattice-based folding protocol based on the Module SIS problem. This folding protocol naturally leads to an efficient recursive lattice-based SNARK and an efficient PCD scheme. LatticeFold supports folding low-degree relations, such as R1CS, as well as high-degree relations, such as CCS. The key challenge is to construct a secure folding protocol that works with the Ajtai commitment scheme. The difficulty, is ensuring that extracted witnesses are low norm through many rounds of folding. We present a novel technique using the sumcheck protocol to ensure that extracted witnesses are always low norm no matter how many rounds of folding are used. Our evaluation of the final proof system suggests that it is as performant as Hypernova, while providing post-quantum security.
Paper Link: https://eprint.iacr.org/2024/257
Skybuffer SAM4U tool for SAP license adoptionTatiana Kojar
Manage and optimize your license adoption and consumption with SAM4U, an SAP free customer software asset management tool.
SAM4U, an SAP complimentary software asset management tool for customers, delivers a detailed and well-structured overview of license inventory and usage with a user-friendly interface. We offer a hosted, cost-effective, and performance-optimized SAM4U setup in the Skybuffer Cloud environment. You retain ownership of the system and data, while we manage the ABAP 7.58 infrastructure, ensuring fixed Total Cost of Ownership (TCO) and exceptional services through the SAP Fiori interface.
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsDianaGray10
Join us to learn how UiPath Apps can directly and easily interact with prebuilt connectors via Integration Service--including Salesforce, ServiceNow, Open GenAI, and more.
The best part is you can achieve this without building a custom workflow! Say goodbye to the hassle of using separate automations to call APIs. By seamlessly integrating within App Studio, you can now easily streamline your workflow, while gaining direct access to our Connector Catalog of popular applications.
We’ll discuss and demo the benefits of UiPath Apps and connectors including:
Creating a compelling user experience for any software, without the limitations of APIs.
Accelerating the app creation process, saving time and effort
Enjoying high-performance CRUD (create, read, update, delete) operations, for
seamless data management.
Speakers:
Russell Alfeche, Technology Leader, RPA at qBotic and UiPath MVP
Charlie Greenberg, host
Digital Banking in the Cloud: How Citizens Bank Unlocked Their MainframePrecisely
Inconsistent user experience and siloed data, high costs, and changing customer expectations – Citizens Bank was experiencing these challenges while it was attempting to deliver a superior digital banking experience for its clients. Its core banking applications run on the mainframe and Citizens was using legacy utilities to get the critical mainframe data to feed customer-facing channels, like call centers, web, and mobile. Ultimately, this led to higher operating costs (MIPS), delayed response times, and longer time to market.
Ever-changing customer expectations demand more modern digital experiences, and the bank needed to find a solution that could provide real-time data to its customer channels with low latency and operating costs. Join this session to learn how Citizens is leveraging Precisely to replicate mainframe data to its customer channels and deliver on their “modern digital bank” experiences.
For the full video of this presentation, please visit: https://www.edge-ai-vision.com/2024/06/how-axelera-ai-uses-digital-compute-in-memory-to-deliver-fast-and-energy-efficient-computer-vision-a-presentation-from-axelera-ai/
Bram Verhoef, Head of Machine Learning at Axelera AI, presents the “How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-efficient Computer Vision” tutorial at the May 2024 Embedded Vision Summit.
As artificial intelligence inference transitions from cloud environments to edge locations, computer vision applications achieve heightened responsiveness, reliability and privacy. This migration, however, introduces the challenge of operating within the stringent confines of resource constraints typical at the edge, including small form factors, low energy budgets and diminished memory and computational capacities. Axelera AI addresses these challenges through an innovative approach of performing digital computations within memory itself. This technique facilitates the realization of high-performance, energy-efficient and cost-effective computer vision capabilities at the thin and thick edge, extending the frontier of what is achievable with current technologies.
In this presentation, Verhoef unveils his company’s pioneering chip technology and demonstrates its capacity to deliver exceptional frames-per-second performance across a range of standard computer vision networks typical of applications in security, surveillance and the industrial sector. This shows that advanced computer vision can be accessible and efficient, even at the very edge of our technological ecosystem.
Fueling AI with Great Data with Airbyte WebinarZilliz
This talk will focus on how to collect data from a variety of sources, leveraging this data for RAG and other GenAI use cases, and finally charting your course to productionalization.
Monitoring and Managing Anomaly Detection on OpenShift.pdfTosin Akinosho
Monitoring and Managing Anomaly Detection on OpenShift
Overview
Dive into the world of anomaly detection on edge devices with our comprehensive hands-on tutorial. This SlideShare presentation will guide you through the entire process, from data collection and model training to edge deployment and real-time monitoring. Perfect for those looking to implement robust anomaly detection systems on resource-constrained IoT/edge devices.
Key Topics Covered
1. Introduction to Anomaly Detection
- Understand the fundamentals of anomaly detection and its importance in identifying unusual behavior or failures in systems.
2. Understanding Edge (IoT)
- Learn about edge computing and IoT, and how they enable real-time data processing and decision-making at the source.
3. What is ArgoCD?
- Discover ArgoCD, a declarative, GitOps continuous delivery tool for Kubernetes, and its role in deploying applications on edge devices.
4. Deployment Using ArgoCD for Edge Devices
- Step-by-step guide on deploying anomaly detection models on edge devices using ArgoCD.
5. Introduction to Apache Kafka and S3
- Explore Apache Kafka for real-time data streaming and Amazon S3 for scalable storage solutions.
6. Viewing Kafka Messages in the Data Lake
- Learn how to view and analyze Kafka messages stored in a data lake for better insights.
7. What is Prometheus?
- Get to know Prometheus, an open-source monitoring and alerting toolkit, and its application in monitoring edge devices.
8. Monitoring Application Metrics with Prometheus
- Detailed instructions on setting up Prometheus to monitor the performance and health of your anomaly detection system.
9. What is Camel K?
- Introduction to Camel K, a lightweight integration framework built on Apache Camel, designed for Kubernetes.
10. Configuring Camel K Integrations for Data Pipelines
- Learn how to configure Camel K for seamless data pipeline integrations in your anomaly detection workflow.
11. What is a Jupyter Notebook?
- Overview of Jupyter Notebooks, an open-source web application for creating and sharing documents with live code, equations, visualizations, and narrative text.
12. Jupyter Notebooks with Code Examples
- Hands-on examples and code snippets in Jupyter Notebooks to help you implement and test anomaly detection models.
Conversational agents, or chatbots, are increasingly used to access all sorts of services using natural language. While open-domain chatbots - like ChatGPT - can converse on any topic, task-oriented chatbots - the focus of this paper - are designed for specific tasks, like booking a flight, obtaining customer support, or setting an appointment. Like any other software, task-oriented chatbots need to be properly tested, usually by defining and executing test scenarios (i.e., sequences of user-chatbot interactions). However, there is currently a lack of methods to quantify the completeness and strength of such test scenarios, which can lead to low-quality tests, and hence to buggy chatbots.
To fill this gap, we propose adapting mutation testing (MuT) for task-oriented chatbots. To this end, we introduce a set of mutation operators that emulate faults in chatbot designs, an architecture that enables MuT on chatbots built using heterogeneous technologies, and a practical realisation as an Eclipse plugin. Moreover, we evaluate the applicability, effectiveness and efficiency of our approach on open-source chatbots, with promising results.
In the realm of cybersecurity, offensive security practices act as a critical shield. By simulating real-world attacks in a controlled environment, these techniques expose vulnerabilities before malicious actors can exploit them. This proactive approach allows manufacturers to identify and fix weaknesses, significantly enhancing system security.
This presentation delves into the development of a system designed to mimic Galileo's Open Service signal using software-defined radio (SDR) technology. We'll begin with a foundational overview of both Global Navigation Satellite Systems (GNSS) and the intricacies of digital signal processing.
The presentation culminates in a live demonstration. We'll showcase the manipulation of Galileo's Open Service pilot signal, simulating an attack on various software and hardware systems. This practical demonstration serves to highlight the potential consequences of unaddressed vulnerabilities, emphasizing the importance of offensive security practices in safeguarding critical infrastructure.
"Choosing proper type of scaling", Olena SyrotaFwdays
Imagine an IoT processing system that is already quite mature and production-ready and for which client coverage is growing and scaling and performance aspects are life and death questions. The system has Redis, MongoDB, and stream processing based on ksqldb. In this talk, firstly, we will analyze scaling approaches and then select the proper ones for our system.
3. Background
• Objec)ve-‐C
is
layered
on
top
of
the
C
–
language
– Based
on
SmallTalk-‐80
– Designed
in
early
1980s
• NeXT
SoLware
licensed
Objec)ve-‐C
in
1988
• Apple
Computer
acquired
NeXT
in
1996
• Today:
na)ve
language
for
developing
Mac
OS
X
-‐
and
iPhone
-‐
apps
8. Compiling
and
Running
TB308POHJUS-L-2:point pohjus$ ls -al
total 32
drwxr-xr-x 6 pohjus staff 204 18 Tou 15:32 .
drwxr-xr-x 3 pohjus staff 102 18 Tou 14:52 ..
-rw-r--r--@ 1 pohjus staff 196 18 Tou 15:25 MyPoint.h
-rw-r--r--@ 1 pohjus staff 268 18 Tou 15:23 MyPoint.m
-rw-r--r--@ 1 pohjus staff 339 18 Tou 15:25 main.m
-rw-r--r--@ 1 pohjus staff 120 18 Tou 15:14 makefile
TB308POHJUS-L-2:point pohjus$ make
clang -fno-objc-arc -framework foundation MyPoint.m main.m -o MyPoint
TB308POHJUS-L-2:point pohjus$ make run
./MyPoint
2009-05-18 15:32:46.339 MyPoint[8725:807] X = 0 and Y = 0
2009-05-18 15:32:46.341 MyPoint[8725:807] X = 8 and Y = 7
TB308POHJUS-L-2:point pohjus$
9. Instan)a)ng
an
Object
// Declare a pointer to the object
MyPoint* point;
// Allocate memory for the object
point = [MyPoint alloc];
// Initialize the object
point = [point init];
10. Instan)a)ng
an
Object:
One
Liner
// Allocate and initialize the object
MyPoint* point1 = [[MyPoint alloc] init];
11. Messages
(Methods)
- (void) setX: (int) n;!
method
type:
+
=
class
method
-‐
=
object
method
return
type
selector
name
argument
type
argument
name
12. Messages,
with
Two
Arguments
Declara=on
- (void) setXAndY: (int) x: (int) y
Usage
[object setXAndY: 5: 6];
Declara=on,
be@er
way
- (void) setX: (int) x andY: (int) y
Usage
[object setX: 5 andY: 6];
15. Memory
Handling
in
General
• When
allocate
something
it
must
be
released
– Memory
consump)on
• In
Java,
garbage
collector
takes
care
of
the
release.
Separate
thread
looking
for
objects
that
can
be
released
• In
Obj-‐C
and
C/C++,
programmer
is
responsible
about
the
release.
16. About
Pointers
• int
a
=
5;
– Holds
one
integer
value
– The
integer
is
stored
in
some
memory
address
• Where?
– You
can
get
the
memory
address
by
using
&
in
front
of
the
variable:
&a
17. Example
of
Memory
Address
int main(int argc, char *argv[])
{
int a = 5;
// prints 5
NSLog(@"%i", a);
// prints something like 0x7fff5fbff9cc
NSLog(@"%p", &a);
return 0;
}
18. Pointers
• Pointer
is
a
variable
that
stores
memory
address
• int
a;
– holds
integer
variable
• int*
b;
– holds
memory
address
that
points
to
integer
value
• int*
b
=
&a;
– Now
b
has
the
memory
address
of
a
19. Example
about
Pointers
#import "MyPoint.h"
int main(int argc, char *argv[])
{
int a = 5;
// Store a's memory address to variable b
int *b = &a;
// prints 5
NSLog(@"%i", a);
// prints something like 0x7fff5fbff9cc
NSLog(@"%p", &a);
// prints something like 0x7fff5fbff9cc
NSLog(@"%p", b);
// prints 5
NSLog(@"%i", *b);
return 0;
}
20. What
is
the
result
now?
int main(int argc, char *argv[])
{
int a = 5;
// Store a's memory address to variable b
int *b = &a;
if(b == &a)
{
NSLog(@"Do we go here?");
}
if(*b == a)
{
NSLog(@"What about here?");
}
return 0;
}
21. What
is
the
result
now?
int main(int argc, char *argv[])
{
int a = 5;
int *b = &a;
*b = 10;
NSLog(@"%i", a);
return 0;
}
22. Memory
Areas
• Memory
can
be
divided
into
three
categories
1. Global
or
sta)c
2. Stack
3. Heap
23. Sta)c
• When
something
is
in
sta)c
memory,
it's
there
all
the
)me
when
app
is
running
• So
when
star)ng
the
app,
the
memory
is
allocated
an
when
the
app
closes,
the
memory
is
deallocated
• The
variable
is
stored
in
the
same
memory
address
all
the
)me.
24. Example
of
Sta)c
Memory
int thisIsStoredInStaticMemory = 5;
int main(int argc, char *argv[])
{
static int thisIsAlsoStoredInStaticMemory = 10;
NSLog(@"My number = %i", thisIsStoredInStaticMemory);
NSLog(@"My number = %i", thisIsAlsoStoredInStaticMemory);
return 0;
}
25. Stack
-‐
Memory
• Stack
–
memoryarea
is
usually
small
• If
you
put
too
much
"stuff"
into
stack,
you
might
get
stack
overflow
• Local
variables
are
stored
in
stack!
• Variables
are
released
when
out
of
scope
26. Example
of
Stack
Memory
int main(int argc, char *argv[])
{
int stack1 = 3;
NSLog(@"My number = %i", stack1);
if(YES)
{
int stack2 = 4;
NSLog(@"My number = %i", stack2);
// stack2 is released from memory now.
}
// stack1 is released from memory now.
return 0;
}
27. Example
of
Stack
Memory
int main(int argc, char *argv[])
{
if(YES)
{
int stack2 = 4;
}
// Does this work?
NSLog(@"My number = %i", stack2);
return 0;
}
28. Heap
-‐
Memory
• Heap
–
memory
is
the
large
memory
area
where
almost
all
of
the
objects
go.
• Programmer
is
responsible
for
releasing
the
objects!
29. Example
of
Heap
-‐
memory
#import "MyPoint.h"
int main(int argc, char *argv[])
{
MyPoint* point = [MyPoint alloc];
//...
[point release];
return 0;
}
30. Crea)ng
a
Object
• The
crea)on
of
an
object
is
done
in
two
parts
• 1)
Alloca)ng
memory
– MyPoint* point = [MyPoint alloc];
• 2)
Ini)alize
object
state
– point = [point init];
• Combined
– MyPoint* point = [[MyPoint alloc] init];
• ó
– MyPoint* point = [MyPoint new];
31. What
happens
in
Memory?
• What
happens
in
here?
– MyPoint* p = [MyPoint alloc];
• Two
things!
– MyPoint* p;
– p = [MyPoint alloc];
• p
is
in
stack
–
memory!
• MyPoint
object
is
in
heap
memory!
33. Problem?
#import "MyPoint.h"
int main(int argc, char *argv[])
{
MyPoint* point = [MyPoint alloc];
point = [MyPoint alloc];
[point release];
return 0;
}
34. init-‐method?
• init-‐method
is
implemented
in
NSObject
• You
can
however
implement
your
own
init-‐
method
- (id) initWithName: (NSString*) aName
{
if(self = [super init])
{
name = aName;
}
return self;
}
35. Other
init-‐methods
• Like
in
Java
and
C++,
one
can
have
mul)ple
constructors
• In
Obj-‐C,
one
can
have
mul)ple
init-‐methods
- (id) init
- (id) initWithX: (int) aX;
- (id) initWithX: (int) aX andY: (int) aY
36. Deallocing
Object
and
Reference
Count
• Rules
about
reference
coun=ng
– When
object
is
created
its
reference
count
is
set
to
1
– Incremen)ng
the
reference
count:
• [point retain];
– Decreasing
reference
count
• [point release];
– When
reference
count
reaches
to
0,
dealloca=ng
occurs
• ARC
will
save
you
from
this!
39. dealloc
• You
can
implement
a
dealloc
method
(void) dealloc
{
// Some code
[super dealloc];
}
40. Reference
Count
Example
#import <Foundation/Foundation.h>
@interface Cat : NSObject
{
NSString* name;
}
- (void) setName: (NSString *) theName
@end
@implementation Cat
- (void) setName: (NSString *) theName
{
name = theName;
}
@end
int main(int argc, char *argv[])
{
....
Cat* mirri = [[Cat alloc] init];
[mirri setName: someName];
// What happens now?
[someName release];
}
Since
reference
count
is
0,
dealloca)on
occurs.
This
means,
that
the
Cat
does
not
have
a
name
anymore.
41. Reference
Count
Example
#import <Foundation/Foundation.h>
@interface Cat : NSObject
{
NSString* name;
}
- (void) setName: (NSString *) theName
@end
@implementation Cat
- (void) setName: (NSString *) theName
{
[name release];
name = theName;
[name retain];
}
@end
int main(int argc, char *argv[])
{
....
Cat* mirri = [[Cat alloc] init];
[mirri setName: someName];
// What happens now?
[someName release];
}
Since
reference
count
is
1,
dealloca)on
does
not
occur
and
the
Cat
s)ll
has
it's
name.
42. Copying
a
Object
- (void)setName:(NSString *)theName
}
[name release];
name = [theName copy];
}
43. Autorelease
Pool
• Every
Founda)on
program
must
set
up
autorelease
pool
for
the
Founda)on
objects
• Pool
keeps
track
of
your
objects
for
later
release
– NSAutoreleasePool *pool = [[NSAutoreleasePool
alloc] init];
– ...
– [pool drain];
44. Method
Names
• If
method
name
includes
alloc
or
copy,
it
returns
a
object
that
must
be
released
– // Must be released
– NSObject* object = [[NSObject alloc] init];
– // Must be released
– NSObject* copy = [object copy];
– // Do not have to release
– NSMutableString* string = [NSMutableString string];
• The
above
string
is
released
in
Autorelease
Pool!
45. Problem
// Programmer A code
[[someObject giveCat] eat];
// Programmer B code
- (Cat*) giveCat
{
// Must be released!
Cat* myCat = [[Cat alloc] init];
// But where? Should the programmer who calls this method be
// responsible for deallocation of the Cat? How does the programmer
// know this?
return myCat;
}
..
46. Solu)on
// Programmer A code
[[someObject giveCat] eat];
// Programmer B code
- (Cat*) giveCat
{
// Must be released!
Cat* myCat = [[Cat alloc] init];
// But where? When autopool is drained!
[myCat autorelease];
return myCat;
}
47. Delayed
Release
• Autorelease
means
"send
release
message
later".
• Release
message
is
sent
when
Autorelease
Pool
is
released
• Autorelease
Pool
is
created
and
released
in
UIKit
programs
automa=cally!
– Pool
is
created
at
the
beginning
of
an
event
cycle
– Pool
is
released
at
the
end
of
an
event
cycle
48. Autorelease
Pools
App
Loaded
Wait
for
Event
Handle
event
Exit
app
Event
loop
Pool
created
Pool
released
49. Autorelease
Pool
Usage
// Method
- (Cat*) giveCat
{
// Must be released!
Cat* myCat = [[Cat alloc] init];
// But where? When autopool is drained!
[myCat autorelease];
return myCat;
}
// Usage
Cat* someCat = [object giveCat];
// someCat will be released in some time, so if you want to hold it, use
// retain
[someCat retain];
50. Rules
• If
method
name
contains
"alloc",
"new"
or
"copy",
you
must
remember
to
use
release
or
autorelease
– Example:
alloc, newObject, mutableCopy
• If
you
retain something,
you
must
use
release or
autorelease
• Instance
Variables:
retain
or
copy
• autorelease
means
"send
release later"
53. main.m
#import "Cat.h"
int main(int argc, char *argv[])
{
NSAutoreleasePool *pool =
[[NSAutoreleasePool alloc] init];
// Create the string
NSString* catName = [[NSString
alloc] initWithString: @"Jack"];
// Create cat with the string
Cat* cat = [[Cat alloc]
initWithName: catName];
// Just testing. This does not
deallocate catName!
[catName release];
// Get the name
NSString* name = [cat getName];
// Print the name
NSLog(name);
// Release name and cat
[cat release];
[pool drain];
return 0;
}
55. ARC?
• ARC
(Automa=c
Reference
Coun=ng)
– Compiler
does
automa/c
reference
coun/ng
by
examining
the
source
code
and
then
add
the
retain
and
release
messages
to
objects
• Not
garbage
collec)on,
no
background
process
of
dealloca)on
of
objects!
• Inserts
retain
and
release
statements
based
on
some
fixed
rules
• OS
X
10.7
and
iOS
5
for
all
features
56. Object
lose
owners
// Scenario 1
Person* jack = [[Person alloc] init];
jack = [[Person alloc] init];
// Scenario 2
Person* tina = [[Person alloc] init];
tina = nil;
// Scenario 3
if(yes) {
Person* dave = [[Person alloc] init];
}
57. Some
Fixed
rules
• If
object
is
allocated
and
local
to
method,
release
statement
is
added
near
the
end
of
that
method
• If
allocated
object
is
class
a@ribute,
release
is
added
to
dealloc
• If
the
object
is
return
value,
it
gets
an
autorelease
statement
58. Guidelines
• Don’t
call!
– retain, release, retainCount, autorelease
or dealloc
• You
must
use
@autoreleasepool
syntax
• You
must
enable
ARC
– clang -fobjc-arc -framework foundation
Car.m Motor.m main.m -o App
71. Property
Declara)on
Aoributes:
Writability
• You
can
decorate
a
property
with
aoributes,
example:
– @property (readonly) int x;
• readwrite
– Indicates
that
the
property
is
read/write.
Default
• readonly
– Only
read
– Generates
only
geoer
method
72. Seoer
Seman)cs
• assign
– Simple
seoer.
Default.
• weak
– Non-‐owning
rela)onship
with
an
object
– If
object
is
deallocated,
the
property
is
set
to
nil
• strong
– Owning
rela)onship
with
an
object
• copy
– Specifies
that
a
copy
of
the
object
should
be
used
for
assignment
82. About
Strings
• C
String
– char * // Array of characters
• NSString
– Object,
that
holds
array
of
Unicode
characters
– Is
immutable,
contents
cannot
be
changed
aLerwards!
• NSMutableString
– String
that
can
be
modified
aLerwards
83. Crea)ng
Strings
// Simple way
NSString *temp1 = @"Hello World!";
// Appending, notice that this produces new string
NSString *beginning = @"beginning";
NSString *alphaAndOmega = [beginning
stringByAppendingString:@" and end"];
84. Formapng
• Formapng
– NSString *string1 = [NSString stringWithFormat:@"A
string: %@, a float: %1.2f", @"string", 31415.9265];
– // string1 is "A string: string, a float: 31415.93"
• Format
Specifiers?
– http://developer.apple.com/iphone/
library/documentation/Cocoa/Conceptual/
Strings/Articles/formatSpecifiers.html#//
apple_ref/doc/uid/TP40004265-SW1
88. Protocols?
• Compared
to
Java,
protocols
are
interfaces
• You
define
methods
that
some
object
must
implement
89. Using
Protocols
// MyProtocolName.h
// Notice that the protocol inherites NSObject
// protocol!
@protocol MyProtocolName <NSObject>
//Method declarations go here
@end
// MyObject
@interface Class: NSObject <MyProtocolName>
90. Protocol
as
Variable
• In
Java
– MyInterface object = new MyObject();
• In
Obj-‐C
– id<MyProtocolName> object = [[MyObject
alloc] init];
• As
a
method
argument
– (void) doSomethingWithThisObject:
(id<MyProtocolName>) aObject
• ID
is
a
predefined
pointer
type
for
an
arbitrary
object