Search completed in 1.48 seconds.
735 results for "Memory":
Your results are loading. Please wait...
Memory - Plugins
« previousnext » this chapter describes the plug-in api functions that allocate and free memory as needed by the plug-in.
... because plug-ins share memory space with the browser, they can take advantage of any customized memory-allocation scheme the browser has.
... browser memory schemes may be more efficient than standard os memory functions, and can give the browser flexibility in the way it manages memory.
...And 31 more matches
about:memory
about:memory is a special page within firefox that lets you view, save, load, and diff detailed measurements of firefox's memory usage.
... it also lets you do other memory-related operations like trigger gc and cc, dump gc & cc logs, and dump dmd reports.
... how to generate memory reports let's assume that you want to measure firefox's memory usage.
...And 30 more matches
Memory reporting
tl;dr: you should read this document before writing a memory reporter.
... and please ask nnethercote to co-review any memory reporter patch.
... mozilla code has infrastructure that lets different parts of the code report on their memory usage.
...And 29 more matches
nsIMemory
xpcom/base/nsimemory.idlscriptable this interface represents a generic memory allocator.
... inherits from: nsisupports last changed in gecko 0.9.6 nsimemory is used to allocate and deallocate memory segments from a heap.
...ns_getmemorymanager returns the global nsimemory instance.
...And 24 more matches
Debugger.Memory - Firefox Developer Tools
debugger.memory the debugger api can help tools observe the debuggee’s memory use in various ways: it can mark each new object with the javascript call stack at which it was allocated.
... ifdbg is a debugger instance, then the methods and accessor properties of dbg.memory control howdbg observes its debuggees’ memory use.
... the dbg.memory object is an instance of debugger.memory; its inherited accesors and methods are described below.
...And 23 more matches
Memory Management - JavaScript
low-level languages like c, have manual memory management primitives such as malloc() and free().
... in contrast, javascript automatically allocates memory when objects are created and frees it when they are not used anymore (garbage collection).
... this automaticity is a potential source of confusion: it can give developers the false impression that they don't need to worry about memory management.
...And 23 more matches
Named Shared Memory
the chapter describes the nspr api for named shared memory.
... shared memory allows multiple processes to access one or more common shared memory regions, using it as an interprocess communication channel.
... the nspr shared memory api provides a cross-platform named shared-memory interface that is modeled on similar constructs in the unix and windows operating systems.
...And 18 more matches
nsIMemoryReporterManager
xpcom/base/nsimemoryreporter.idlscriptable a service that provides methods for managing nsimemoryreporter objects.
... inherits from: nsisupports last changed in gecko 1.9 (firefox 3) implemented by @mozilla.org/memory-reporter-manager;1 as a service: var reportermanager = components.classes["@mozilla.org/memory-reporter-manager;1"] .getservice(components.interfaces.nsimemoryreportermanager); each memory reporter object, which implements nsimemoryreporter interface, provides information for a given code area.
... each code area is identified by a unique path string, which is displayed in about:memory.
...And 17 more matches
WebAssembly.Memory() constructor - JavaScript
the webassembly.memory() constructor creates a new memory object whose buffer property is a resizable arraybuffer or sharedarraybuffer that holds the raw bytes of memory accessed by a webassembly instance.
... a memory created by javascript or in webassembly code will be accessible and mutable from both javascript and webassembly.
... syntax new webassembly.memory(memorydescriptor); parameters memorydescriptor an object that can contain the following members: initial the initial size of the webassembly memory, in units of webassembly pages.
...And 14 more matches
Infallible memory allocation
there's ongoing work to implement infallible memory allocators.
... these are memory allocation routines that never return null; that is, they always successfully return the requested block of memory.
... this is in contrast to a traditional, fallible memory allocator that can return null indicating that the request failed.
...And 13 more matches
Memory Profiler
firefox developer tools now has a built-in memory profiler.
... getting the profiler add-on the built-in memory profiler's interface is still under construction.
... it can be obtained by installing the memory profiler add-on.
...And 12 more matches
Anonymous Shared Memory
this chapter describes the nspr api for anonymous shared memory.
... anonymous memory protocol anonymous shared memory functions anonymous memory protocol nspr provides an anonymous shared memory based on nspr's prfilemap type.
... the anonymous file-mapped shared memory provides an inheritable shared memory, as in: the child process inherits the shared memory.
...And 12 more matches
WebAssembly.Memory - JavaScript
the webassembly.memory object is a resizable arraybuffer or sharedarraybuffer that holds the raw bytes of memory accessed by a webassembly instance.
... a memory created by javascript or in webassembly code will be accessible and mutable from both javascript and webassembly.
... constructor webassembly.memory() creates a new memory object.
...And 12 more matches
nsIMemoryReporter
xpcom/base/nsimemoryreporter.idlscriptable reports memory usage information for a single area of the software.
... 1.0 66 introduced gecko 1.9 inherits from: nsisupports last changed in gecko 8.0 (firefox 8.0 / thunderbird 8.0 / seamonkey 2.5) any piece of code that wishes to allow its memory use to be monitored may create an nsimemoryreporter object and then register it by calling nsimemoryreportermanager.registerreporter().
... once that has been done, the reporter will be found by any client accessing the enumerator returned by nsimemoryreportermanager.enumeratereporters().
...And 11 more matches
Choosing the right memory allocator
there are a lot of different memory allocators in the mozilla source tree.
... allocating memory in xpcom these are general purpose memory-management routines that you should use unless your code falls into one of the other categories below.
... ns_alloc() == nsimemory::alloc() ns_realloc() == nsimemory::realloc() ns_free() == nsimemory::free() nsmemory::clone() (note: not part of nsimemory) see infallible memory allocation for information about how to allocate memory infallibly; that is, how to use memory allocators that will only return valid memory buffers, and never return null.
...And 10 more matches
PR_OpenSharedMemory
opens an existing shared memory segment or, if one with the specified name doesn't exist, creates a new one.
... syntax #include <prshm.h> nspr_api( prsharedmemory * ) pr_opensharedmemory( const char *name, prsize size, printn flags, printn mode ); /* define values for pr_opensharememory(...,create) */ #define pr_shm_create 0x1 /* create if not exist */ #define pr_shm_excl 0x2 /* fail if already exists */ parameters the function has the following parameters: name the name of the shared memory segment.
... size the size of the shared memory segment.
...And 8 more matches
JS::SetOutOfMemoryCallback
this article covers features introduced in spidermonkey 31 specify a new callback function for out of memory error.
... syntax void js::setoutofmemorycallback(jsruntime *rt, js::outofmemorycallback cb, void *data); name type description rt jsruntime * the jsruntime for which to set the gc callback.
... cb js::outofmemorycallback pointer to the new callback function to use.
...And 6 more matches
nsMemory
« xpcom api reference summary the nsmemory class provides static helper routines to manage memory.
... these routines allow easy access to xpcom's global nsimemory implementation without having to go through the service manager to get it.
... #include "nsmemory.h" class nsmemory { ...
...And 6 more matches
Memory Management Operations
this chapter describes the global functions and macros you use to perform memory management.
... nspr provides heap-based memory management functions that map to the familiar malloc(), calloc(), realloc(), and free().
... memory allocation functions memory allocation macros memory allocation functions nspr has its own heap, and these functions act on that heap.
...And 5 more matches
nsIMemoryMultiReporter
xpcom/base/nsimemoryreporter.idlscriptable reports multiple memory measurements using a callback function that gets called once for each measurement.
...the callback, which must implement the nsimemorymultireportercallback interface, receives values that match the fields in the nsimemoryreporter object.
...this will call the specified callback's nsimemorymultireportercallback.callback() method once for each report.
...And 4 more matches
Planned changes to shared memory - JavaScript
these changes provide further isolation between sites and help reduce the impact of attacks with high-resolution timers, which can be created with shared memory.
... for top-level documents, two headers will need to be set: cross-origin-opener-policy with same-origin as value (protects your origin from attackers) cross-origin-embedder-policy with require-corp as value (protects victims from your origin) with these two headers set, postmessage() will no longer throw for sharedarraybuffer objects and shared memory across threads is therefore available.
...webassembly.memory can still be used to get an instance.
...And 4 more matches
Debugging out-of-memory problems
a common bug to diagnose with emscripten is where a big game fails due to an out of memory error (oom) somewhere during load time.
... by the time about:memory is loaded in a new tab and you have clicked the "measure" button to diagnose what's happened, the memory usage causing the spike has gone away, making temporary memory spikes difficult to diagnose.
... out-of-memory exceptions from js setting memory.dump_reports_on_oom in about:config to true will cause the browser to automatically write about:memory dumps to a temp file printed to the browser console (note: not web console) when an oom crash is encountered.
...And 3 more matches
JS_EnumerateDiagnosticMemoryRegions
this article covers features introduced in spidermonkey 17 enumerate memory regions that contain diagnostic information..
... syntax void js_enumeratediagnosticmemoryregions(jsenumeratediagnosticmemorycallback callback); name type description callback jsenumeratediagnosticmemorycallback pointer to the new callback function to use.
... callback syntax typedef bool (* jsenumeratediagnosticmemorycallback)(void *ptr, size_t length); name type description ptr void * pointer to the allocated memory.
...And 3 more matches
JS_ReportOutOfMemory
reports a memory allocation error.
... syntax void js_reportoutofmemory(jscontext *cx); void js_reportallocationoverflow(jscontext *cx); // added in spidermonkey 1.8 name type description cx jscontext * the context in which to report the error.
... description call js_reportoutofmemory to report that an operation failed because the system is out of memory.
...And 3 more matches
Aggregating the In-Memory Datasource
introduction you can use xpcom aggregation1 with the in-memory datasource.
...say you were writing a datasource2, and the way you chose to implement it was to "wrap" the in-memory datasource; i.e., myclass : public nsimyinterface, public nsirdfdatasource { private: nscomptr<nsirdfdatasource> minner; public: // nsirdfdatasource methods ns_imethod init(const char* auri) { return minner->init(auri); } ns_imethod geturi(char* *auri) { return minner->geturi(auri); } // etc., for each method in nsirdfdatasource!
... when it won't work although this magic is terribly convenient to use, it won't work in the case that you want to "override" some of the in-memory datasource's methods.
...And 3 more matches
Memory - Firefox Developer Tools
the memory tool lets you take a snapshot of the current tab's memory heap.
... it then provides a number of views of the heap that can show you which objects account for memory usage and exactly where in your code you are allocating memory.
... the basics opening the memory tool taking a heap snapshot comparing two snapshots deleting snapshots saving and loading snapshots recording call stacks analyzing snapshots the tree map view is new in firefox 48, and the dominators view is new in firefox 46.
...And 3 more matches
PR_AttachSharedMemory
attaches a memory segment previously opened with pr_opensharedmemory and maps it into the process memory space.
... syntax #include <prshm.h> nspr_api( void * ) pr_attachsharedmemory( prsharedmemory *shm, printn flags ); /* define values for pr_attachsharedmemory(...,flags) */ #define pr_shm_readonly 0x01 parameters the function has these parameters: shm the handle returned from pr_opensharedmemory.
... flags options for mapping the shared memory.
...And 2 more matches
JS_SetGCParametersBasedOnAvailableMemory
this article covers features introduced in spidermonkey 31 adjust performance parameters related to garbage collection based on available memory.
... syntax void js_setgcparametersbasedonavailablememory(jsruntime *rt, uint32_t availmem); name type description rt jsruntime * the runtime to configure.
... value uint32_t the value of available memory in megabytes.
...And 2 more matches
NS_GetMemoryManager
« xpcom api reference summary the ns_getmemorymanager function returns a reference to the xpcom memory manager.
... #include "nsxpcom.h" #include "nsimemory.h" nsresult ns_getmemorymanager( nsimemory** aresult ); parameters aresult [out] a reference to the xpcom memory manager.
... return values the ns_getmemorymanager function returns ns_ok if successful.
...And 2 more matches
Memory Management
memory management if js code creates a structure or an array, that memory will be valid as long as the js object stays alive.
... pointers to that memory must be carefully managed to make sure the underlying memory is still referenced.
... when binary code hands back a pointer/handle to allocated memory, the js code must make sure to free that memory with the correct allocator.
...And 2 more matches
WebAssembly.Memory.prototype.grow() - JavaScript
the grow() protoype method of the memory object increases the size of the memory instance by a specified number of webassembly pages.
... syntax memory.grow(number); parameters number the number of webassembly pages you want to grow the memory by (each one is 64kib in size).
... return value the previous size of the memory, in units of webassembly pages.
...And 2 more matches
NSS Memory allocation
nss makes extensive use of nspr's plarenapools for memory allocation.
... each block of memory allocated in a plarenapool is called a plarena.
...when nss attempts to allocate more memory for an arena pool, the plarenapool code attempts to use an arena from its free list, and only gets a new arena from the heap if there are no arenas in the free list that are large enough to satisfy the request.
...but leak analysis tools only record the allocation of memory from the heap, not memory from the arena free list, so they will always show the first allocation (from the heap) and not the most recent allocation (from the arena free list).
JS_SetICUMemoryFunctions
sets the memory allocation and deallocation functions used by the icu internationalization library.
... syntax bool js_seticumemoryfunctions(js_icuallocfn allocfn, js_icureallocfn reallocfn, js_icufreefn freefn); type description allocfn js_icuallocfn an allocation function.
... description js_seticumemoryfunctions sets the allocator functions used by the icu internationalization library.
...mxr id search for js_seticumemoryfunctions.
GetGlobalMemoryService
« xpcom api reference summary the getglobalmemoryservice function returns a reference to xpcom's global nsimemory object.
... static nsimemory* getglobalmemoryservice(); return values this function returns nsnull if the global memory manager does not exist or could not be initialized.
... remarks this function returns the same value as the ns_getmemorymanager function.
... see also ns_getmemorymanager ...
nsIMemoryMultiReporterCallback
xpcom/base/nsimemoryreporter.idlscriptable implement this interface to handle callbacks from nsimemorymultireporter instances.
...void callback( in acstring process, in autf8string path, in print32 kind, in print32 units, in print64 amount, in autf8string description, in nsisupports closure ); parameters process the value of the process attribute for the memory reporter.
... closure an nsisupports object providing any additional data the callback might need; you provide this when you call nsimemorymultireporter.collectreports().
... see also nsimemorymultireporter nsimemoryreportermanager nsimemoryreporter ...
Device Memory API - Web APIs
accessing device memory capacity there are two ways to acces the approximate amount of ram device has: via javascript api and via client hints http header.
... javascript api you may query the approximate amount of ram device has by retreiving navigator.devicememory var ram1 = window.navigator.devicememory; var ram2 = navigator.devicememory; both of these will return the same result.
... client hints header you also may use client hints directive device-memory to retreive the same approximate ram capacity.
... specifications specification status comment device memory 1 editor's draft initial definition.
Navigator.deviceMemory - Web APIs
the devicememory read-only property of the navigator interface returns the approximate amount of device memory in gigabytes.
...it is then clamped within lower and upper bounds to protect the privacy of owners of very low- or high-memory devices.
... syntax memoryamount = navigator.devicememory value a floating point number; one of 0.25, 0.5, 1, 2, 4, 8.
... example const memory = navigator.devicememory console.log (`this device has at least ${memory}gib of ram.`) specifications specification status comment device memory 1the definition of 'devicememory' in that specification.
Device-Memory - HTTP
the device-memory header is a device memory api header that works like client hints header which represents the approximate amount of ram client device has.
...server has to opt in to receive device-memory header from the client by sending accept-ch and accept-ch-lifetime response headers.
... device-memory: <number> examples server first needs to opt in to receive device-memory header by sending the response headers accept-ch containing device-memory and accept-ch-lifetime.
... accept-ch: device-memory accept-ch-lifetime: 86400 then on subsequent requests the client might send device-memory header back: device-memory: 1 specifications specification status comment device memory 1the definition of 'device-memory' in that specification.
WebAssembly.Memory.prototype.buffer - JavaScript
the buffer prototype property of the webassembly.memory object returns the buffer contained in the memory.
... examples using buffer the following example (see memory.html on github, and view it live also) fetches and instantiates the loaded memory.wasm byte code using the webassembly.instantiatestreaming() method, while importing the memory created in the line above.
... it then stores some values in that memory, then exports a function and uses it to sum some values.
... webassembly.instantiatestreaming(fetch('memory.wasm'), { js: { mem: memory } }) .then(obj => { var i32 = new uint32array(memory.buffer); for (var i = 0; i < 10; i++) { i32[i] = i; } var sum = obj.instance.exports.accumulate(0, 10); console.log(sum); }); specifications specification webassembly javascript interfacethe definition of 'buffer' in that specification.
Common causes of memory leaks in extensions - Extensions
this page explains coding patterns that cause extension to cause memory leaks.
... causes of zombie compartments zombie compartments are a particular kind of memory leak.
... components.utils.unload("chrome://myaddon/content/mymodule.jsm"); } note: modules not belonging to your add-on — such as services.jsm — should not be unloaded by your add-on, as this might cause errors and/or performance regressions and will actually increase the memory usage.
PR_DetachSharedMemory
unmaps a shared memory segment identified by name.
... syntax #include <prshm.h> nspr_api( prstatus ) pr_detachsharedmemory( prsharedmemory *shm, void *addr ); parameters the function has these parameters: shm the handle returned from pr_opensharedmemory.
... addr the address to which the shared memory segment is mapped.
PR_CloseSharedMemory
closes a shared memory segment identified by name.
... syntax #include <prshm.h> nspr_api( prstatus ) pr_closesharedmemory( prsharedmemory *shm ); parameter the function has these parameter: shm the handle returned from pr_opensharedmemory.
PR_DeleteSharedMemory
deletes a shared memory segment identified by name.
... syntax #include <prshm.h> nspr_api( prstatus ) pr_deletesharedmemory( const char *name ); parameter the function has these parameter: shm the handle returned from pr_opensharedmemory.
isLowMemory
this content is now available at nsimemory.islowmemory().
Performance.memory - Web APIs
syntax timinginfo = performance.memory attributes jsheapsizelimit the maximum size of the heap, in bytes, that is available to the context.
MMgc - Archive of obsolete content
mmgc is the tamarin (née macromedia) garbage collector, a memory management library that has been built as part of the avm2/tamarin effort.
...unmanaged memory mmgc is not only a garbage collector, but a general-purpose memory manager.
... the flash player uses it for nearly all memory allocations.
...And 80 more matches
Understanding WebAssembly text format - WebAssembly
so that means the webassembly s-expression: (module (memory 1) (func)) represents a tree with the root node “module” and two child nodes, a "memory" node with the attribute "1" and a "func" node.
... to create an equivalent value using javascript, you'd use the webassembly.global() constructor: const global = new webassembly.global({value: "i32", mutable: true}, 0); webassembly memory the above example is a pretty terrible logging function: it only prints a single integer!
...to deal with strings and other more complex data types, webassembly provides memory (although we also have reference types in newer implementation of webassembly).
...And 41 more matches
Using the WebAssembly JavaScript API - WebAssembly
memory in the low-level memory model of webassembly, memory is represented as a contiguous range of untyped bytes called linear memory that are read and written by load and store instructions inside the module.
... in this memory model, any load or store can access any byte in the entire linear memory, which is necessary to faithfully represent c/c++ concepts like pointers.
... unlike a native c/c++ program, however, where the available memory range spans the entire process, the memory accessible by a particular webassembly instance is confined to one specific — potentially very small — range contained by a webassembly memory object.
...And 29 more matches
Index
7 gcintegration developing mozilla, firefox, garbage collection, intermediate, intro, jsapi, needsupdate, spidermonkey, tools, memory the spidermonkey garbage collector (gc) will be changing a lot in the future.
...the allocation will then be retried (and may still fail.) 68 js::setoutofmemorycallback jsapi reference, reference, référence(2), spidermonkey unlike the error reporter, which is only called if the exception for an oom bubbles up and is not caught, the js::outofmemorycallback is called immediately at the oom site to allow the embedding to capture the current state of heap allocation before anything is freed.
... if the large-allocation-failure callback is called at all (not all allocation sites call the large-allocation-failure callback on failure), it is called before the out-of-memory callback; the out-of-memory callback is only called if the allocation still fails after the large-allocation-failure callback has returned.
...And 24 more matches
Index
MozillaTechXPCOMIndex
3 aggregating the in-memory datasource rdf no summary!
...this is useful particularly when testing for memory leaks, because normal garbage collection is conservative when javascript code is running to ensure that in-use memory isn't inadvertently collected.
... 97 xpcom glue without mozalloc starting with xulrunner 2.0, the frozen linkage dependent glue (xpcomglue_s.lib on windows, libxpcomglue_s.a on linux and mac) is dependent on the new infallible memory allocation routines (mozalloc).
...And 24 more matches
DMD
in this mode, dmd tracks the contents of the heap, including which heap blocks have been reported by memory reporters.
... it helps us reduce the "heap-unclassified" value in firefox's about:memory page, and also detects if any heap blocks are reported twice.
...this is good for understanding how memory is used at an interesting point in time, such as peak memory usage.
...And 20 more matches
Zombie compartments
this page tells you how to detect and avoid zombie compartments, which are a particular kind of memory leak.
... compartments firefox’s javascript memory is segregated into zones and compartments.
... roughly speaking, all memory used by javascript code that is from a particular origin (i.e.
...And 16 more matches
HTTP Cache
when there is no profile the new http cache works, but everything is stored only in memory not obeying any particular limits.
... currently we have 3 types of storages, all the access methods return an nsicachestorage object: memory-only (memorycachestorage): stores data only in a memory cache, data in this storage are never put to disk disk (diskcachestorage): stores data on disk, but for existing entries also looks into the memory-only storage; when instructed via a special argument also primarily looks into application caches application cache (appcachestorage): when a consumer has a specific nsiap...
...a particular app cache version in a group) in hands, this storage will provide read and write access to entries in that application cache; when the app cache is not specified, this storage will operate over all existing app caches the service also provides methods to clear the whole disk and memory cache content or purge any intermediate memory structures: clear – after it returns, all entries are no longer accessible through the cache apis; the method is fast to execute and non-blocking in any way; the actual erase happens in background purgefrommemory – removes (schedules to remove) any intermediate cache data held in memory for faster access (more about the intermediate cache below) nsiloadcontextinfo distinguishes...
...And 13 more matches
Sqlite.jsm
easier memory management.
... since sqlite.jsm manages statements for you, it can perform intelligent actions like purging all cached statements not in use, freeing memory in the process.
... there is even a shrinkmemory api that will minimize memory usage of the connection automatically.
...And 13 more matches
Web Replay
ipc integration allows a replaying process to communicate with the chrome process using ipdl and shared memory.
... inter-thread non-determinism is handled by first assuming the program is data race free: shared memory accesses which would otherwise race are either protected by locks or use apis that perform atomic operations.
... if we record and later replay the order in which threads acquire locks (and, by extension, release locks and use condvars) then accesses on lock-protected memory will occur in the same order.
...And 13 more matches
JSAPI User Guide
the engine handles memory allocation for the objects needed to execute scripts, and it cleans up—garbage collects—objects it no longer needs.
... garbage collection as it runs, javascript code implicitly allocates memory for objects, strings, variables, and so on.
... garbage collection is the process by which the javascript engine detects when those pieces of memory are no longer reachable—that is, they could not possibly ever be used again—and reclaims the memory.
...And 11 more matches
Avoiding leaks in JavaScript XPCOM components
using xpcom in javascript (also known as xpconnect) is an environment where memory management issues are not obvious.
... basics of memory management creating objects that are not a fixed size for the lifetime of the program (global variables) or a fixed size for the lifetime of a function (stack variables) requires a system for dynamic memory allocation: a system that allocates memory from a space called the heap.
... the requirements for such a memory allocation system are: memory should be returned to the heap when the program no longer needs it (or soon thereafter) so that the amount of memory consumed by the program does not increase.
...And 11 more matches
Starting WebLock
mponent as an xpcom-startup observer, do the following: char* previous = nsnull; rv = catman->addcategoryentry("xpcom-startup", "weblock", weblock_contractid, pr_true, // persist category pr_true, // replace existing &previous); if (previous) nsmemory::free(previous); // free the memory the replaced value might have used the unregistration, which should occur in the unregistration callback, looks like this: rv = catman->deletecategoryentry("xpcom-startup", "weblock", pr_true); // persist a complete code listing for registering weblock as a startup observer follows: #defi...
...ne mozilla_strict_api #include "nsigenericfactory.h" #include "nscomptr.h" #include "nsxpcom.h" #include "nsiservicemanager.h" #include "nsicategorymanager.h" #include "nsmemory.h" #include "nsiobserver.h" #include "nsembedstring.h" #define weblock_cid \ { 0x777f7150, 0x4a2b, 0x4301, \ { 0xad, 0x10, 0x5e, 0xab, 0x25, 0xb3, 0x22, 0xaa}} #define weblock_contractid "@dougt/weblock" class weblock: public nsiobserver { public: weblock(); virtual ~weblock(); ns_decl_isupports ns_decl_nsiobserver }; weblock::weblock() { ns_init_isupports(); } weblock::~weblock() { } ns_impl_isupports1(weblock, nsiobserver); ns_imethodimp weblock::observe(nsisupports *asubject, const char *atopic, const prunichar *adata) { return ns_ok; } static ns_method weblockregistration(nsicompon...
... getter_addrefs(catman)); if (ns_failed(rv)) return rv; char* previous = nsnull; rv = catman->addcategoryentry("xpcom-startup", "weblock", weblock_contractid, pr_true, pr_true, &previous); if (previous) nsmemory::free(previous); return rv; } static ns_method weblockunregistration(nsicomponentmanager *acompmgr, nsifile *apath, const char *registrylocation, const nsmodulecomponentinfo *info) { nsresult rv; nscomptr<nsiservicemanager> servman = do_queryinterface((nsisupports*)acompmg...
...And 11 more matches
Initialization and Destruction - Plugins
shutdown: when the last instance of a plug-in is deleted, the plug-in code is unloaded from memory and the browser calls the function np_shutdown.
...use this function to allocate the memory and resources shared by all instances of your plug-in.
... nperror np_initialize(void) { }; after the last plug-in instance is deleted, the browser calls np_shutdown, which releases the memory or resources allocated by np_initialize.
...And 11 more matches
Performance fundamentals - Web Performance
memory usage memory usage is another key metric.
... unlike responsiveness and framerate, users don't directly perceive memory usage, but memory usage closely approximates "user state".
... an ideal system would maintain 100% of user state at all times: all applications in the system would run simultaneously, and all applications would retain the state created by the user the last time the user interacted with the application (application state is stored in computer memory, which is why the approximation is close).
...And 11 more matches
Shell global objects
rror messages and debug info linenumber starting line number for error messages and debug info columnnumber starting column number for error messages and debug info global global in which to execute the code newcontext if true, create and use a new cx (default: false) catchtermination if true, catch termination (failure without an exception value, as for slow scripts or out-of-memory) and return 'terminated' element if present with value v, convert v to an object o and mark the source as being attached to the dom element o.
...the object retrieved may not be identical to the object that was installed, but it references the same shared memory.
... getsharedarraybuffer performs an ordering memory barrier.
...And 10 more matches
Performance
memory profiling and leak detection tools the developer tools "memory" panel the memory panel in the devtools supports taking heap snapshots, diffing them, computing dominator trees to surface "heavy retainers", and recording allocation stacks.
... about:memory about:memory is the easiest-to-use tool for measuring memory usage in mozilla code, and is the best place to start.
... it also lets you do other memory-related operations like trigger gc and cc, dump gc & cc logs, and dump dmd reports.
...And 9 more matches
Index - Web APIs
WebAPIIndex
103 audiobuffer api, audiobuffer, interface, reference, web audio api the audiobuffer interface represents a short audio asset residing in memory, created from an audio file using the audiocontext.decodeaudiodata() method, or from raw data using audiocontext.createbuffer().
... 112 audiobuffersourcenode api, audio, audiobuffersourcenode, interface, media, reference, web audio api the audiobuffersourcenode interface is an audioscheduledsourcenode which represents an audio source consisting of in-memory audio data, stored in an audiobuffer.
... it's especially useful for playing back audio which has particularly stringent timing accuracy requirements, such as for sounds that must match a specific rhythm and can be kept in memory rather than being played from disk or the network.
...And 9 more matches
WebGL best practices - Web APIs
the only errors a well-formed page generates are out_of_memory and context_lost.
... for example, within firefox, the only time glgeterror is checked is after allocations (bufferdata, *teximage*, texstorage*) to pick up any gl_out_of_memory errors.
... estimate a per-pixel vram budget webgl doesn't offer apis to query the maximum amount of video memory on the system because such queries are not portable.
...And 9 more matches
NSS_3.12_release_notes.html
bug 354403: nsslist_createiterator returns pointer to a freed memory if the function fails to allocate a lock bug 399236: pkix wrapper must print debug output into stderr bug 399300: pkix error results not freed after use.
...bug 429388: vfychain.main leaks memory bug 396044: warning: usage of uninitialized variable in ckfw/object.c(174) bug 396045: warning: usage of uninitialized variable in ckfw/mechanism.c(719) bug 401986: mac os x leopard build failure in legacydb bug 325805: diff considers mozilla/security/nss/cmd/pk11util/scripts/pkey a binary file bug 385151: remove the link time dependency from nss to softoken bug 387892: add entrust root ca certificate(s) to nss bug 433386: when system clock is off by more than two days, oscp check fails, can result in crash if user tries to view certificate [[@ secitem_compareitem_util] [[@ memcmp] bug 396256: certutil and pp do not print all the generalnames in a crldp extension b...
... 345779: useless assignment statements in ec_gf2m_pt_mul_mont bug 349011: please stop exporting these crmf_ symbols bug 397178: crash when entering chrome://pippki/content/resetpassword.xul in url bar bug 403822: pkix_pl_ocsprequest_create can leave some members uninitialized bug 403910: cert_findusercertbyusage() returns wrong certificate if multiple certs with same subject available bug 404919: memory leak in sftkdb_readsecmoddb() (sftkmod.c) bug 406120: allow application to specify ocsp timeout bug 361025: support for camellia cipher suites to tls rfc4132 bug 376417: pk11_generatekeypair needs to get the key usage from the caller.
...And 8 more matches
ssltyp.html
upgraded documentation may be found in the current nss reference selected ssl types and structures chapter 3 selected ssl types and structures this chapter describes some of the most important types and structures used with the functions described in the rest of this document, and how to manage the memory used for them.
... types and structures managing secitem memory types and structures these types and structures are described here: certcertdbhandle certcertificate pk11slotinfo secitem seckeyprivatekey secstatus additional types used by a single function only are described with the function's entry in each chapter.
...when an application makes a copy of a particular certificate structure that already exists in memory, ssl makes a shallow copy--that is, it increments the reference count for that object rather than making a whole new copy.
...And 8 more matches
Index - Firefox Developer Tools
21 debugger.memory the debugger api can help tools observe the debuggee’s memory use in various ways: 22 debugger.object a debugger.object instance represents an object in the debuggee, providing reflection-oriented methods to inspect and modify its referent.
... 37 memory devtools, firefox, mozilla, tools the memory tool lets you take a snapshot of the current tab's memory heap.
... it then provides a number of views of the heap that can show you which objects account for memory usage and exactly where in your code you are allocating memory.
...And 8 more matches
Overview of Mozilla embedding APIs
these classes provide a variety of string operations as well as dealing with the memory management issues of storing the underlying data.
... nsmemory nsmemory::alloc nsmemory::realloc nsmemory::free this helper class provides static accessors to the global nsmemory service.
...implemented interfaces: nsiservicemanager related interfaces: nsishutdownlistener nsmemory the nsmemory service provides the global memory manager implementation for xpcom.
...And 7 more matches
NSS API Guidelines
memory allocation with arenas this section discusses memory allocation using arenas.
... nss makes use of traditional memory allocation functions, wrapping nspr's pr_alloc in a util function called port_alloc.
... though nss makes further use of an nspr memory-allocation facility which uses 'arenas' and 'arenapools'.
...And 7 more matches
JS_malloc
allocate and free memory that is not managed by the garbage collector.
... p void * (js_realloc and js_free only) pointer to a previously allocated region of memory to resize or deallocate.
... description js_malloc allocates a region of memory nbytes in size.
...And 7 more matches
Mozilla
choosing the right memory allocator there are a lot of different memory allocators in the mozilla source tree.
... getting from content to layout gecko maintains two separate representations of a document in memory: the content tree and the frame tree.
... infallible memory allocation there's ongoing work to implement infallible memory allocators.
...And 7 more matches
Dominators view - Firefox Developer Tools
starting in firefox 46, the memory tool includes a new view called the dominators view.
...it looks something like this: the dominators view consists of two panels: the dominators tree panel shows you which nodes in the snapshot are retaining the most memory the retaining paths panel (new in firefox 47) shows the 5 shortest retaining paths for a single node.
... dominators tree panel the dominators tree tells you which objects in the snapshot are retaining the most memory.
...And 7 more matches
NPN_MemAlloc - Archive of obsolete content
« gecko plugin api reference « plug-in side plug-in api summary allocates memory from the browser's memory space.
... syntax #include <npapi.h> void *npn_memalloc (uint32 size); parameters the function has the following parameters: size size of memory, in bytes, to allocate in the browser's memory space.
... returns if successful, the function returns a pointer to the allocated memory, in bytes.
...And 6 more matches
Hacking Tips
$ sudo cgcreate -a nicolas:users -t nicolas:users -g cpuset,cpu,memory:/benchmarks $ cgcreate -a nicolas:users -t nicolas:users -g cpuset,cpu,memory:/benchmarks/mask $ cgcreate -a nicolas:users -t nicolas:users -g cpuset,cpu,memory:/benchmarks/negate-mask then we restrict programs of these groups to the first core of the cpu.
... $ cgset -r cpuset.cpus=0 /benchmarks $ cgset -r cpuset.cpus=0 /benchmarks/mask $ cgset -r cpuset.cpus=0 /benchmarks/negate-mask then we restrict programs of these groups to the first memory node.
... $ cgset -r cpu.shares=1 /benchmarks/mask $ cgset -r cpu.shares=39 /benchmarks/negate-mask then we limit the memory available, to what would be available on the phone.
...And 6 more matches
Realloc
« xpcom api reference summary the realloc function reallocates a block of memory to a new size.
... static void* realloc( void* aptr, size_t asize ); parameters aptr [in] the address of the memory block to reallocate.
... this may be nsnull, in which case realloc behaves like nsmemory::alloc.
...And 6 more matches
EventTarget.addEventListener() - Web APIs
(see memory issues, below.) the value of "this" within the handler it is often desirable to reference the element on which the event handler was fired, such as when using a generic handler for a set of similar elements.
... getting data into and out of an event listener using objects unlike most functions in javascript, objects are retained in memory as long as a variable referencing them exists in memory.
...(hence they too can have properties, and will be retained in memory even after they finish executing if assigned to a variable that persists in memory.) because object properties can be used to store data in memory as long as a variable referencing the object exists in memory, you can actually use them to get data into an event listener, and any changes to the data back out after an event handler executes.
...And 6 more matches
Index - Archive of obsolete content
640 stress testing consume.exe from the windows server 2003 resource kit tools can consume various resources: physical memory, cpu time, page file, disk space and even the kernel pool.
... use the --memory flag to capture the maximum private bytes memory (high water mark) for a test.
... 667 the life of an html http request developing mozilla, docshell, guide, necko, needsupdate 668 the new nsstring class implementation (1999) outdated_articles, xpcom this document is intended to briefly describe the new nsstring class architecture, and discuss the implications on memory management, optimizations, internationalization and usage patterns.
...And 5 more matches
NPN_MemFlush - Archive of obsolete content
requests that the browser free a specified amount of memory.
... syntax #include <npapi.h> uint32 npn_memflush(uint32 size); parameters the function has the following parameters: size size of memory, in bytes, to free in the browser's memory space.
... returns if successful, the function returns the amount of freed memory, in bytes.
...And 5 more matches
Eclipse CDT
system requirements eclipse will use a lot of memory to fully index the mozilla source tree to provide code assistance features (easily 4 gb of ram, although this will drop to just over 1 gb if you restart after indexing is complete).
...since it's a pain to install them and keep them up to date we do not recommend getting eclipse this way.) increase eclipse's memory limits!
... before you use eclipse with the mozilla source you must increase its memory limits.
...And 5 more matches
BloatView
bloatview is a tool that shows information about cumulative memory usage and leaks.
... reading individual bloat logs full bloatview output contains per-class statistics on allocations and refcounts, and provides gross numbers on the amount of memory being leaked broken down by class.
...note that this number does not reflect any memory held onto by the class, such as internal buffers, etc.
...And 5 more matches
Index
in order to support multiple operating systems (os), it is based on a cross platform portability layer, called the netscape portable runtime (nspr), which provides cross platform application programming interfaces (apis) for os specific apis like file system access, memory management, network communication, and multithreaded programming.
...nss will usually create an in-memory (ram) presentation of certificates, once a certificate has been received from the network, read from disk, or looked up from the database, and prepare in-memory data structures that contain the certificate's properties, as well as providing a handle for the programmer to use.
... when dealing with memory, nss makes use of arenas, which are an attempt to simplify management with the limited offerings of c (because there are no destructors).
...And 5 more matches
Garbage collection
principal data structures cell a cell is the unit of memory that is allocated and collected by the gc, as used externally.
... compartments are a fundamental cross-cutting concept in spidermonkey (see also compartments), though anything related to memory is now more concerned with zones, especially gc.
... chunk a chunk is the largest internal unit of memory allocation.
...And 5 more matches
Secure Development Guidelines
and bottom of current stack frame status register (eflags) contains various state information instruction pointer (eip) points to register being executed; can’t be modified directly introduction: gaining control (2) eip is modified using call or jump instructions attacks usually rely on obtaining control over the eip otherwise the attacker can try to control memory pointed to by an existing function pointer a vulnerability is required to modify the eip or sensitive memory saved return addr or function pointer get altered introduction: gaining control (3) common issues used to gain control buffer overflows format string bugs integer overflows/underflows writing secure code: input validation input validation most vulnerabilities ...
...a/b : 0; } writing secure code: memory management string handling c-style strings are byte arrays that end with a \0 byte some string handling functions won’t perform any kind of length checking, so don’t use them ensure your string is always \0 terminated!
... bbv: stack overflow example: void foo(char *bar) { char c[12]; strcpy(c, bar); } int main(int argc, char **argv) { foo(argv[1]); } bbv: stack overflow before the stack overflow bbv: stack overflow after the stack overflow bbv: heap overflow dynamic memory malloc() calloc() heapalloc() mmap() not on the stack segment!
...And 5 more matches
Allocations - Firefox Developer Tools
the allocations view in the performance tool shows you which functions in your page are allocating the most memory over the course of the profile.
... for performance this is important mostly because allocating a lot of memory, or making a lot of allocations, can trigger garbage collection.
... so in the example above: 8904 samples were taken in signallater(), which is 28.57% of the total number of samples taken those samples allocated 1102888 bytes, which is 30.01% of the total memory allocated in all samples next to each function name is a disclosure arrow.
...And 5 more matches
Modularization techniques - Archive of obsolete content
however, a poor implementation of these functions can have negative results, such as memory leaks or inadvertent access of freed objects.
... } return mrefcnt; } ns_imethodimp nssamplefactory::createinstance(nsisupports *aouter, const nsiid &aiid, void **aresult) { if (aresult == null) { return ns_error_null_pointer; } *aresult = null; nsisupports inst = new nssample(); if (inst == null) { return ns_error_out_of_memory; } nsresult res = inst->queryinterface(aiid, aresult); if (res != ns_ok) { // we didn't get the right interface, so clean up delete inst; } return res; } void nssamplefactory::lockfactory(prbool alock) { // not implemented in simplest case.
... } nsresult getsamplefactory(nsifactory **aresult) { if (aresult == null) { return ns_error_null_pointer; } *aresult = null; nsisupports inst = new nssamplefactory(); if (inst == null) { return ns_error_out_of_memory; } nsresult res = inst->queryinterface(kifactoryiid, aresult); if (res != ns_ok) { // we didn't get the right interface, so clean up delete inst; } return res; } file main.cpp main.cpp is a simple program that creates an instance of our sample class and disposes of it.
...And 4 more matches
RDF Datasource How-To - Archive of obsolete content
for example, you may choose to delegate to the in-memory datasource, which is a generic datasource that implements nsirdfdatasource.
... typically, you provide a parser for reading in some sort of static storage (e.g., a data file); the parser translates the datafile into a series of calls to assert() to set up the in-memory datasource.
... when flush() is called, or the last reference to the datasource is released, a routine walks the in-memory datasource and re-serializes the graph back to the original file format.
...And 4 more matches
The new nsString class implementation (1999) - Archive of obsolete content
this document is intended to briefly describe the new nsstring class architecture, and discuss the implications on memory management, optimizations, internationalization and usage patterns.
...the deficiencies of the current implementation are: class based -- making it unsuitable for cross-dll usage due to fragility little intrinsic i18n support few efficiencies, notably a lack of support for narrow (1-byte) character strings no support for external memory management policy lack of xpcom interface notable features of the new nsstrimpl implementation are: intrinsic support for 1 and 2 byte character widths provides automatic conversion between strings with different character sizes inviolate base structure eliminates class fragility problem; safe across dll boundaries offers c-style function api to manipulate nsstrimpl offers simple memory a...
...llocator api for specialized memory policy shares binary format with bstring coming soon: a new xpcom (nsistring) interface non-templatized; this is a requirement for gecko very efficient buffer manipulation architecture the fundamental data type in the new architecture is struct nsstrimpl, given below: struct nsstrimpl { print32 mlength; void* mbuffer; print32 mcapacity; char mcharsize; char munused; // and now for the nsstrimpl api...
...And 4 more matches
Debugging on Windows
setting breakpoints in dlls which are not yet loaded in memory vc++ 6.0: go to project > settings..., debug tab and select "additional dlls" from the drop down list.
...one requires setting an environment variable, while the other affects only the currently running program instance in memory.
... it is possible to change the interrupt code in memory (which causes you to break into debugger) to be a nop (no operation).
...And 4 more matches
An overview of NSS Internals
in order to support multiple operating systems (os), it is based on a cross platform portability layer, called the netscape portable runtime (nspr), which provides cross platform application programming interfaces (apis) for os specific apis like file system access, memory management, network communication, and multithreaded programming.
...nss will usually create an in-memory (ram) presentation of certificates, once a certificate has been received from the network, read from disk, or looked up from the database, and prepare in-memory data structures that contain the certificate's properties, as well as providing a handle for the programmer to use.
... when dealing with memory, nss makes use of arenas, which are an attempt to simplify management with the limited offerings of c (because there are no destructors).
...And 4 more matches
JSAPI reference
ror handling struct jserrorformatstring added in spidermonkey 17 class jserrorreport class js::autosaveexceptionstate added in spidermonkey 31 enum jsexntype added in spidermonkey 17 js_reporterror js_reportwarning js_reporterrornumber js_reporterrornumberuc js_reporterrorflagsandnumber js_reporterrorflagsandnumberuc js_reporterrornumberucarray added in spidermonkey 24 js_reportoutofmemory js_reportallocationoverflow added in spidermonkey 1.8 js_geterrorreporter js_seterrorreporterobsolete since jsapi 52 js_errorfromexception js_geterrorprototype jsreport_is_exception jsreport_is_strict jsreport_is_warning jsreport_is_strict_mode_error the following functions allow c/c++ functions to throw and catch javascript exceptions: js::createerror added in spidermonkey 38 js_i...
...2 jsval_to_double obsolete since jsapi 32 jsval_to_object obsolete since jsapi 32 jsval_to_string obsolete since jsapi 32 jsval_to_gcthing obsolete since jsapi 32 jsval_to_private obsolete since jsapi 32 a function that behaves like typeof: js_gettypename obsolete since jsapi 34 and functions that behave like the equality operators: js_strictlyequal js_looselyequal js_samevalue memory management these functions act like the standard c malloc family of functions, except that errors are reported using the spidermonkey error apis rather than errno.
...these functions provide access to the garbage collector: js_gc js_maybegc js_getgcparameter js_setgcparameter js_getgcparameterforthread added in spidermonkey 17 js_setgcparameterforthread added in spidermonkey 17 js_setgcparametersbasedonavailablememory added in spidermonkey 31 enum jsgcparamkey js_setgccallback enum jsgcstatus js_addfinalizecallback added in spidermonkey 38 enum jsfinalizestatus added in spidermonkey 17 js_removefinalizecallback added in spidermonkey 38 js_setgczeal added in spidermonkey 1.8 js_schedulegc added in spidermonkey 17 js_dumpheap added in spidermonkey 1.8 js_setgccallbackrt...
...And 4 more matches
NS_Realloc
« xpcom api reference summary reallocates a block of memory using the xpcom memory manager.
... #include "nsxpcom.h" void* ns_realloc( void* aptr, prsize asize ); parameters aptr [in] a pointer to the block of memory to reallocate.
... this pointer must have been previously allocated by the xpcom memory manager, or this parameter may be null in which case this function behaves like ns_alloc.
...And 4 more matches
SharedArrayBuffer - JavaScript
the sharedarraybuffer object is used to represent a generic, fixed-length raw binary data buffer, similar to the arraybuffer object, but in a way that they can be used to create views on shared memory.
... description allocating and sharing memory to share memory using sharedarraybuffer objects from one agent in the cluster to another (an agent is either the web page’s main program or one of its web workers), postmessage and structured cloning is used.
... var sab = new sharedarraybuffer(1024); worker.postmessage(sab); updating and synchronizing shared memory with atomic operations shared memory can be created and updated simultaneously in workers or the main thread.
...And 4 more matches
Plug-in Development Overview - Gecko Plugin API Reference
handling memory plug-in developers can take advantage of the memory features provided in the plug-in api to allocate and free memory.
... use the npn_memalloc method to allocate memory from the browser.
... use the npn_memfree method to free memory allocated with npn_memalloc.
...And 3 more matches
Investigating leaks using DMD heap scan mode
firefox’s dmd heap scan mode tracks the set of all live blocks of malloc-allocated memory and their allocation stacks, and allows you to log these blocks, and the values stored in them, to a file.
...--mode=scan is needed so that when we get a dmd log the entire contents of each block of memory is saved for later analysis.
...if your leak is a ghost window, it can be handy to get an about:memory report and write down the pid of the leaking process.
...And 3 more matches
Gecko Profiler FAQ
even about:memory would be more useful.
... how can i run (micro-?) benchmarks on the memory allocator to see if changes in it (or entire allocator replacements) are slower/faster?
... do we profile memory page faults?
...And 3 more matches
PR_Realloc
resizes allocated memory on the heap.
... syntax #include <prmem.h> void *pr_realloc ( void *ptr, pruint32 size); parameters ptr a pointer to the existing memory block being resized.
... size the size of the new memory block.
...And 3 more matches
PR_Unmap
unmap a memory region that is backed by a memory-mapped file.
... syntax #include <prio.h> prstatus pr_memunmap( void *addr, pruint32 len); parameters the function has the following parameters: addr the starting address of the memory region to be unmapped.
... len the length, in bytes, of the memory region.
...And 3 more matches
An Overview of XPCOM
xpcom not only supports component software development, it also provides much of the functionality that a development platform provides, such as: component management file abstraction object message passing memory management we will discuss the above items in detail in the coming chapters, but for now, it can be useful to think of xpcom as a platform for component development, in which features such as those listed above are provided.
...when this happens, interfaces may never be released and will leak memory.
...the difference is a subtle one, since interface pointers and regular pointers are both just addresses in memory.
...And 3 more matches
Clone
« xpcom api reference summary the clone function creates a copy of an existing memory block up to the size specified.
... static void* clone( const void* aptr, size_t asize ); parameters aptr [in] the address of the memory block to copy.
...asize [in] specifies the new size in bytes of the block of memory to allocate.
...And 3 more matches
Plug-in Development Overview - Plugins
handling memory plug-in developers can take advantage of the memory features provided in the plug-in api to allocate and free memory.
... use the npn_memalloc method to allocate memory from the browser.
... use the npn_memfree method to free memory allocated with npn_memalloc.
...And 3 more matches
Aggregate view - Firefox Developer Tools
each type gets a row in the table, and rows are ordered by the amount of memory occupied by objects of that type.
... for example, in the screenshot above you can see that javascript objects account for most memory, followed by strings.
... because tracing allocations has a runtime cost, it must be explicitly enabled by checking "record call stacks" before you allocate the memory in the snapshot.
...And 3 more matches
Basic operations - Firefox Developer Tools
opening the memory tool before firefox 50, the memory tool is not enabled by default.
... to enable it, open the developer tool settings, and check the "memory" box under "default firefox developer tools": from firefox 50 onwards, the memory tool is enabled by default.
...on the left, you'll see an entry for the new snapshot, including its timestamp, size, and controls to save or clear this snapshot: clearing a snapshot to remove a snapshot, click the "x" icon: saving and loading snapshots if you close the memory tool, all unsaved snapshots will be discarded.
...And 3 more matches
WebXR performance guide - Web APIs
this section will combine information from https://github.com/immersive-web/webxr/blob/master/explainer.md#controlling-depth-precision and https://github.com/immersive-web/webxr/blob/master/explainer.md#preventing-the-compositor-from-using-the-depth-buffer optimizing memory use when using libraries that perform things such as matrix mathematics, you typically have a number of working variables through which various vectors, matrices, and quaternions pass over time.
...they can be thought of as being similar to the registers in a microprocessor: a limited set of memory storage slots for specific kinds of data or use cases.
... while an individual vector or matrix doesn't occupy an inordinate amount of memory, the sheer number of vectors and matrices and other structures that are used to build each frame of a 3d scene means the memory management becomes a problem eventually if you keep allocating and de-allocating memory objects.
...And 3 more matches
Compiling an Existing C Module to WebAssembly - WebAssembly
for that, you need to expose two additional functions — one that allocates memory for the image inside wasm and one that frees it up again: #include <stdlib.h> // required for malloc definition emscripten_keepalive uint8_t* create_buffer(int width, int height) { return malloc(width * height * 4 * sizeof(uint8_t)); } emscripten_keepalive void destroy_buffer(uint8_t* p) { free(p); } the create_buffer() function allocates a buffer for the rgba image — hence 4 bytes per ...
...the pointer returned by malloc() is the address of the first memory cell of that buffer.
...because functions in c can't have arrays as return types (unless you allocate memory dynamically), this example resorts to a static global array.
...And 3 more matches
Performance best practices in extensions - Archive of obsolete content
general performance tips avoid creating memory leaks memory leaks require the garbage collector and the cycle collector to work harder, which can significantly degrade performance.
... zombie compartments are a particular kind of memory leak that you can detect with minimal effort.
... see common causes of memory leaks in extensions for ways to avoid zombie compartments and other kinds of leaks.
...And 2 more matches
NPN_SetValue - Archive of obsolete content
display; true=windowed, false=windowless nppvplugintransparentbool: sets transparent mode for display of a plugin; true=transparent, false=opaque nppvjavaclass nppvpluginwindowsize nppvplugintimerinterval nppvpluginscriptableinstance nppvpluginscriptableiid nppvjavascriptpushcallerbool: specifies whether you are pushing or popping the jscontext off the stack nppvpluginkeeplibraryinmemory: tells browser that the plugin dll should live longer than usual nppvpluginneedsxembed nppvpluginscriptablenpobject nppvformvalue nppvplugindrawingmodel value the value of the specified variable to be set.
... nppvpluginkeeplibraryinmemory specifies that the plugin does not want to be unloaded from memory after the page which initiated it has gone.
... normally, when the browser navigates away from the page containing the plugin, all plugin instances get an npp_destroy call, and if there are no more instances of the plugin active, the plugin calls its np_shutdown method and the plugin dll gets unloaded from memory.
...And 2 more matches
HTML parser threading
(the same runnable is used repeatedly in order to avoid cross-thread refcounting issues.) memory management when crossing the thread boundary the tree ops hold various heap-allocated objects that end up crossing the thread boundary.
... these objects are memory managed as follows: attribute holders (nshtml5htmlattributes objects) are allocated using new by the tokenizer.
...a handle points to memory allocated by the tree builder and guaranteed to stick around for the life time of the parser.
...And 2 more matches
Leak And Bloat Tests
this page describes how to perform tests that measure memory leaks and bloat for mailnews and its sub-components.
... aim to provide a continuous check within mailnews and its sub-components for the following items: total memory leaks.
... total memory usage (aka bloat).
...And 2 more matches
PL_strdup
returns a pointer to a new memory node in the nspr heap containing a copy of a specified string.
...if the memory allocation fails, null.
... description to accommodate the terminator, the size of the allocated memory is one greater than the length of the string being copied.
...And 2 more matches
PR_MemMap
maps a section of a file to memory.
... syntax #include <prio.h> void* pr_memmap( prfilemap *fmap, print64 offset, pruint32 len); parameters the function has the following parameters: fmap a pointer to the file-mapping object representing the file to be memory-mapped.
... returns the starting address of the memory region to which the section of file is mapped.
...And 2 more matches
JS::Add*Root
description the js::add*root and functions add a c/c++ variable to the garbage collector's root set, the set of variables used as starting points each time the collector checks to see what memory is reachable.
... the garbage collector aggressively collects and recycles memory that it deems unreachable, so roots are often necessary to protect data from being prematurely collected.
...that could cause sporadic crashes during garbage collection, which can be hard to debug.) the variable must remain in memory until the balancing call to js::remove*root.
...And 2 more matches
JS_AddExternalStringFinalizer
register a custom string memory manager.
...it is the callback's responsibility to free the memory.
... after this callback, the js engine will not use that memory anymore and will not keep a pointer to it.
...And 2 more matches
JS_Add*Root
description the js_add*root and functions add a c/c++ variable to the garbage collector's root set, the set of variables used as starting points each time the collector checks to see what memory is reachable.
... the garbage collector aggressively collects and recycles memory that it deems unreachable, so roots are often necessary to protect data from being prematurely collected.
...that could cause sporadic crashes during garbage collection, which can be hard to debug.) the variable must remain in memory until the balancing call to js_removeroot.
...And 2 more matches
SpiderMonkey 1.8
js_reportallocationoverflow can be used (instead of js_reportoutofmemory) to indicate that the script is trying to do something that would require more memory than the implementation is designed to handle.
... many new memory management features have been added as well.
... a new gc parameter, jsgc_stackpool_lifespan, controls how eagerly spidermonkey returns unused memory back to the system.
...And 2 more matches
Redis Tips
you may encounter articles on the web trying to scare you away from using lots of small zsets due to their memory consumption.
... i recommend instead reading about redis's memory optimizations for small zsets: http://oldblog.antirez.com/post/everything-about-redis-24.html.
... maybe the data doesn't belong in your redis memory at all?
...And 2 more matches
Creating the Component Code
if that fails, return an out of memory error code.
... ns_imethodimp samplefactory::createinstance(nsisupports *aouter, const nsiid & iid, void * *result) { if (!result) return ns_error_invalid_arg; sample* sample = new sample(); if (!sample) return ns_error_out_of_memory; nsresult rv = sample->queryinterface(iid, result); if (ns_failed(rv)) { *result = nsnull; delete sample; } return rv; } weblock1.cpp before any of the improvements and xpcom tools we describe in the following chapter are brought in, the source code for the weblock component that implements all the necessary interfaces looks like this.
...fcnt) samplefactory::release() { if (--mrefcnt == 0) { delete this; return 0; } return mrefcnt; } ns_imethodimp samplefactory::createinstance(nsisupports *aouter, const nsiid & iid, void * *result) { if (!result) return ns_error_invalid_arg; sample* sample = new sample(); if (!sample) return ns_error_out_of_memory; nsresult rv = sample->queryinterface(iid, result); if (ns_failed(rv)) { *result = nsnull; delete sample; } return rv; } ns_imethodimp samplefactory::lockfactory(prbool lock) { return ns_error_not_implemented; } // module implementation class samplemodule : public nsimodule { public: samplemodule(); virtual ~samplemodule(); // nsisupports methods: ns_im...
...And 2 more matches
Detailed XPCOM hashtable guide
some: hashtables are not packed structures; depending on the implementation, there may be significant wasted memory.
...good hashtable implementations will automatically resize the hashtable in memory if extra space is needed, or if too much space has been allocated.
... mozilla's hashtable implementations mozilla has several hashtable implementations, which have been tested and, tuned, and hide the inner complexities of hashtable implementations: pldhash - low-level c api; stores keys and data in one large memory structure; uses the heap efficiently; client must declare an "entry class" and may not hold onto entry pointers.
...And 2 more matches
Mozilla internal string guide
an example: const nsastring& str = getsomestring(); nsastring::const_iterator start, end; str.beginreading(start); str.endreading(end); constexpr auto valueprefix = u"value="_ns; if (findinreadable(valueprefix, start, end)) { // end now points to the character after the pattern valuestart = end; } checking for memory allocation failure the string classes now use infallible memory allocation, so you do not need to check for success when allocating/resizing "normal" strings.
...see unicode conversion for more details and for better ways that don't require you to manage the memory yourself.
...representing ascii as utf-16 bad both for memory usage and cache locality.
...And 2 more matches
NS_Alloc
« xpcom api reference summary infallibly allocates a block of memory using the xpcom memory manager.
... return values this function returns a pointer to the allocated block of memory, which is suitably aligned for any kind of variable, or null if the allocation failed.
... remarks this function provides a convenient way to access the xpcom memory manager.
...And 2 more matches
NS_Free
« xpcom api reference summary frees a block of memory using the xpcom memory manager.
... #include "nsxpcom.h" void ns_free( void* aptr ); parameters aptr [in] a pointer to the block of memory to free.
... remarks this function provides a convenient way to access the xpcom memory manager.
...And 2 more matches
Alloc
« xpcom api reference summary the alloc function allocates a block of memory of a particular size.
... static void* alloc( size_t asize ); parameters asize [in] specifies the size in bytes of the block of memory to allocate.
...the result must be freed with a call to nsmemory::free() when it is no longer needed.
...And 2 more matches
Performance
caching sqlite has a cache of database pages in memory.
...you can control the size of the memory cache using the cache_size pragma.
... this value controls the number of pages of the file that can be kept in memory at once.
...And 2 more matches
URLs - Plugins
you can use npn_posturl to post data to a url from a memory buffer or file.
...the data to post can be contained either in a local temporary file or a new memory buffer.
...to post data from a memory buffer, set the flag file to false, the buffer buf to the data to post, and len to the length of the buffer.
...And 2 more matches
Gecko Plugin API Reference - Plugins
plug-in display modes using the object element for plug-in display nesting rules for html elements using the appropriate attributes using the embed element for plug-in display using custom embed attributes plug-in references plug-in development overview writing plug-ins registering plug-ins ms windows unix mac os x drawing a plug-in instance handling memory sending and receiving streams working with urls getting version and ui information displaying messages on the status line making plug-ins scriptable building plug-ins building, platforms, and compilers building carbonized plug-ins for mac os x type libraries installing plug-ins native installers xpi plug-ins installations plug-in installation and the windows...
... stream to the plug-in sending the stream in random-access mode sending the stream in file mode sending a stream creating a stream pushing data into the stream deleting the stream example of sending a stream urls getting urls getting the url and displaying the page posting urls posting data to an http server uploading files to an ftp server sending mail memory allocating and freeing memory mac os flushing memory (mac os only) version, ui, and status information displaying a status line message getting agent information getting the current version finding out if a feature exists reloading a plug-in plug-in side plug-in api this chapter describes methods in the plug-in api that are available from the plug-in object.
... npn_memalloc allocates memory from the browser's memory space.
...And 2 more matches
Dominators - Firefox Developer Tools
these concepts matter in memory analysis, because often an object may itself be small, but may hold references to other much larger objects, and by doing this will prevent the garbage collector from freeing that extra memory.
... you can see the dominators in a page using the dominators view in the memory tool.
... with a garbage-collected language, like javascript, the programmer doesn't generally have to worry about deallocating memory.
...And 2 more matches
Cognitive accessibility - Accessibility
cognitive skills include: attention memory processing speed time management letters and language numbers symbols and math understanding and making choices a solid approach to providing accessible solutions for people with cognitive impairments includes: delivering content in more than one way, such as by text-to-speech or by video; providing easily-understood content, such as text written using plain-language standards; focusi...
... people who have a poor short-term memory, or who are multitasking.
...people with cognitive disabilities, limited short-term memory, and reading disabilities all benefit from being able to identify the purpose of content this way.
...And 2 more matches
<details>: The Details disclosure element - HTML: Hypertext Markup Language
WebHTMLElementdetails
the computer must have some memory and ideally some kind of long-term storage.
...the computer must have some memory and ideally some kind of long-term storage.
...the computer must have some memory and ideally some kind of long-term storage.
...And 2 more matches
WebAssembly Concepts - WebAssembly
webassembly is a low-level assembly-like language with a compact binary format that runs with near-native performance and provides languages with low-level memory models such as c++ and rust with a compilation target so that they can run on the web.
... (note that webassembly has the high-level goal of supporting languages with garbage-collected memory models in the future.) with the advent of webassembly appearing in browsers, the virtual machine that we talked about earlier will now load and run two types of code — javascript and webassembly.
... memory: a resizable arraybuffer that contains the linear array of bytes read and written by webassembly’s low-level memory access instructions.
...And 2 more matches
Setting Up a Development Environment - Archive of obsolete content
leak monitor memory leaks have always been a big criticism drawn against firefox.
... mozilla has proven with time that they take memory usage seriously, improving performance on several critical areas and removing all kinds of memory leaks.
... however, extensions are also capable of causing memory leaks.
... if you want your extension to be included in the mozilla add-ons site, you better not have any memory leaks.
NPN_MemFree - Archive of obsolete content
« gecko plugin api reference « plug-in side plug-in api summary deallocates a block of allocated memory.
... syntax #include <npapi.h> void npn_memfree (void* ptr); parameters the function has the following parameters: ptr block of memory previously allocated using npn_memalloc.
... description npn_memfree deallocates a block of memory that was allocated using npn_memalloc only.
... npn_memfree does not free memory allocated by any other means.
Mozilla accessibility architecture
when there is no dom node for each accessible, as is the case for nshtmlcomboboxaccessible and nsxultreeitemaccessible, we also need to override the shutdown() method, so that the children get removed from memory when the parent is shutdown.
...why we need accessibility cache the accessibility cache has a number of purposes: stability: because the gecko dom and layout teams want to avoid memory bloat where necessary, we could not afford to use 4 bytes on dom or layout nodes to point back to accessible objects.
...these crashes occur when the assistive techology releases after some gecko modules have already been unloaded, when the necessary destructors no longer exist in memory.
...if we do not shut down nodes that go away, we cause more memory footprint than necessary.
Are We Slim Yet
the are we slim yet project (commonly known as awsy) for several years tracked memory usage across builds on the (now defunct) website areweslimyet.com.
... it used the same infrastructure as about:memory to measure memory usage on a predefined snapshot of alexa top 100 pages known as tp5.
... as new processes are added to firefox we want to make sure their memory usage is also tracked by awsy.
... to this end we request that memory reporting be integrated into any new process before it is enabled on nightly.
reader.parse-on-load.force-enabled
the preference reader.parse-on-load.force-enabled controls if the reader mode used in firefox mobile should be enabled independent of the memory available in the device.
... by default, the reader mode in firefox mobile is only enabled if the memory is greater than 384mb.
... type:boolean default value: false exists by default: yes application support:firefox mobile 23.0 status: active; last updated 2013-05-11 introduction: pushed to nightly on 2013-05-06 bugs: bug 867875 values true reader mode is enabled independent of memory available.
... false (default) reader mode is only enabled if memory available exceeds a threshold (currenlty 384mb).
PRFileMap
syntax #include <prio.h> typedef struct prfilemap prfilemap; description the opaque structure prfilemap represents a memory-mapped file object.
... before actually mapping a file to memory, you must create a memory-mapped file object by calling pr_createfilemap, which returns a pointer to prfilemap.
... then sections of the file can be mapped into memory by passing the prfilemap pointer to pr_memmap.
... the memory-mapped file object is closed by passing the prfilemap pointer to pr_closefilemap.
PR_Calloc
allocates zeroed memory from the heap for a number of objects of a given size.
... returns an untyped pointer to the allocated memory, or if the allocation attempt fails, null.
... description this function allocates memory on the heap for the specified number of objects of the specified size.
... all bytes in the allocated memory are cleared.
PR_MALLOC
allocates memory of a specified size from the heap.
... syntax #include <prmem.h> void * pr_malloc(_bytes); parameter _bytes size of the requested memory block.
... returns an untyped pointer to the allocated memory, or if the allocation attempt fails, null.
... description this macro allocates memory of the requested size from the heap.
JS_NewExternalString
create a new jsstring whose characters are stored in external memory.
...the array must be populated with the desired character data before js_newexternalstring is called, and the array must remain in memory, with its contents unchanged, for as long as the javascript engine needs to hold on to it.
...obsolete since jsapi 13 description js_newexternalstring and js_newexternalstringwithclosure create a new jsstring whose characters are stored in external memory, i.e., memory allocated by the application, not the javascript engine.
... since the program allocated the memory, it will need to free it; this happens in an external string finalizer indicated by the type parameter.
SpiderMonkey 31
when all jsapi operation has completed, the corresponding js_shutdown method (currently non-mandatory, but highly recommended as it may become mandatory in the future) uninitializes spidermonkey, cleaning up memory and allocations performed by js_init.
... js_seticumemoryfunctions is a new function which can be used to set the allocation and deallocation functions used by the icu internationalization library.
... this is unlikely to be of interest to embedders unless you are doing detailed memory profiling.
... once all jsapi operation has completed, the corresponding js_shutdown method uninitializes spidermonkey, cleaning up memory and allocations performed by js_init.
Components.utils.Sandbox
this helps to improve memory usage by allowing sandboxes to be discarded when that zone goes away.
... sandboxname a string value which identifies the sandbox in about:memory (and possibly other places in the future).
... this property is optional, but very useful for tracking memory usage of add-ons and other javascript compartments.
... freeing the sandbox when you have finished using a sandbox, it should be freed to avoid memory leaks.
mozIStorageConnection
storage/public/mozistorageconnection.idlscriptable this interface represents a database connection attached to a specific file or an in-memory database.
...null if the database connection refers to an in-memory database.
... exceptions thrown ns_error_unexpected the connection is to a memory database.
...it loads pages from the start of the database file until the memory cache (specified by "pragma cache_size=") is full or the entire file is read.
Add to iPhoto
basic cftype routines handle memory management, dumping cftype objects to the console, comparing cftype values, and so forth.
...it returns a cfstringref, which is a pointer to the new string, and accepts, as input, three parameters: an allocator, which is a pointer to a routine that will allocate the memory to contain the new object (we use the ctypes.voidptr_t type for this), a pointer to the unicode string to copy into the new string object (ctypes.jschar.ptr), and the length of the unicode string in characters.
... cfarray the cfarray type is used to create arrays of objects; the objects in the array can be of any type, thanks to a set of callbacks you can provide to handle managing their memory and performing operations such as comparisons.
...to specify a pointer to the fsref indicating the application to launch, we pass ref.address(), which obtains the actual memory address of the c data structure.
Plug-in Basics - Plugins
when the user opens a page that contains embedded data of a media type that invokes a plug-in, the browser responds with the following sequence of actions: check for a plug-in with a matching mime type load the plug-in code into memory initialize the plug-in create a new instance of the plug-in gecko can load multiple instances of the same plug-in on a single page, or in several open windows at the same time.
...when the last instance of a plug-in is deleted, the plug-in code is unloaded from memory.
... the following stages outline the life of a plug-in from loading to deletion: when gecko encounters data of a mime type registered for a plug-in (either embedded in an html page or in a separate file), it dynamically loads the plug-in code into memory, if it hasn't been loaded already, and it creates a new instance of the plug-in.
... when the last instance of a plug-in is deleted, the plug-in code is unloaded from memory.
WebGLRenderingContext.pixelStorei() - Web APIs
pixel storage parameters parameter name (for pname) description type default value allowed values (for param) specified in gl.pack_alignment packing of pixel data into memory glint 4 1, 2, 4, 8 opengl es 2.0 gl.unpack_alignment unpacking of pixel data from memory.
... glint 0 0 to infinity opengl es 3.0 gl.pack_skip_pixels number of pixel locations skipped before the first pixel is written into memory.
... glint 0 0 to infinity opengl es 3.0 gl.pack_skip_rows number of rows of pixel locations skipped before the first pixel is written into memory glint 0 0 to infinity opengl es 3.0 gl.unpack_row_length number of pixels in a row.
... glint 0 0 to infinity opengl es 3.0 gl.unpack_image_height image height used for reading pixel data from memory glint 0 0 to infinity opengl es 3.0 gl.unpack_skip_pixels number of pixel images skipped before the first pixel is read from memory glint 0 0 to infinity opengl es 3.0 gl.unpack_skip_rows number of rows of pixel locations skipped before the first pixel is read from memory glint 0 0 to infinity opengl es 3.0 gl.unpack_skip_images number of pixel images skipped before the first pixel is read from memory glint 0 0 to infinity opengl es 3.0 examples setting the pixel storage mode affects the webglrenderingcontext.readpixels() operations, as well as unpacking of textures with...
Compressed texture formats - Web APIs
these are useful to increase texture detail while limiting the additional video memory necessary.
... if supported, textures can be stored in a compressed format in video memory.
... this allows for additional detail while limiting the added video memory necessary.
... note that webgl makes no functionality available to compress or decompress textures: they must already be in a compressed format and can then be directly uploaded to video memory.
Large-Allocation - HTTP
webassembly or asm.js applications can use large contiguous blocks of allocated memory.
...the large-allocation tells the browser that the web content in the to-be-loaded page is going to want to perform a large contiguous memory allocation and the browser can react to this header by starting a dedicated process for the to-be-loaded document, for example.
... this message means that the browser saw the large-allocation header, and was able to reload the page into a new process which should have more available contiguous memory.
... firefox currently only supports the large-allocation header in our 32-bit windows builds, as memory fragmentation is not an issue in 64-bit builds.
Appendix D: Loading Scripts - Archive of obsolete content
javascript files or urls may be loaded in this manner by first retrieving their contents into memory using an xmlhttprequest.
...this means that any and all javascript objects passed in our out of them are wrapped in inter-compartment proxy objects, which consume additional memory and add an extra layer of complexity to all property accesses and method calls.
...unlike modules, however, scripts are still executed each time they are loaded and therefore still suffer performance and memory disadvantages over that method.
Source code directories overview - Archive of obsolete content
netwerk contains c interfaces and code for low-level access to the network (using sockets and file and memory caches) as well as higher-level access (using various protocols such as http, ftp, gopher, castanet).
...the "c" runtime library contains basic non-visual c functions to allocate and deallocate memory, get the time and date, read and write files, handle threads and handling and compare strings across all platforms.
...leaky can help detect memory leaks and xpcom reference counting problems.
Mozilla Application Framework in Detail - Archive of obsolete content
necko features include support for asynchronous i/o, a generic disk and memory cache service, asynchronous caching dns resolution, web proxies, and https.
...it is a development environment that provides the following features for the cross-platform software developer: component management file abstraction object message passing memory management this component object model makes virtually all of the functionality of gecko available as a series of components, or reusable cross-platform libraries, that can be accessed from the browser or scripted from any mozilla application.
...engine; java integration with a bridge to xpcom, a java dom api, the open jvm integration (oji) facility, a java webclient api, and java plug-ins; nspr, a runtime engine that provides platform-independence (across over a dozen platforms) for non-gui operating system facilities with support for threads, thread synchronization, normal file and network i/o, interval timing and calendar time, basic memory management (malloc and free) and shared library linking; psm, a set of libraries that perform cryptographic operations including setting up an ssl connection, object signing and signature verification, certificate management (including issuance and revocation), other common pki functions, and s/mime support; an sql support that provides the ability to set up data sources, query a database, and ...
NPN_PostURL - Archive of obsolete content
the data to post can be contained either in a local temporary file or a new memory buffer.
... to post data from a memory buffer, set the flag file to false, the buffer buf to the data to post, and len to the length of buffer.
...you cannot use npn_posturl to specify headers (even a blank line) in a memory buffer.
NPAPI plugin reference - Archive of obsolete content
npn_memalloc allocates memory from the browser's memory space.
... npn_memflush requests that the browser free a specified amount of memory.
... npn_memfree deallocates a block of allocated memory.
Garbage collection - MDN Web Docs Glossary: Definitions of Web-related terms
often abbreviated "gc," garbage collection is a fundamental component of the memory management system used by javascript.
... learn more general knowledge memory management on wikipedia garbage collection on wikipedia technical reference garbage collection in the mdn javascript guide.
... memory management in javascript ...
Framework main features - Learn web development
this abstraction away from the dom is more complex and more memory-intensive than updating the dom yourself, but without it, frameworks could not allow you to program in the declarative way they’re known for.
... the virtual dom is an approach whereby information about your browser's dom is stored in javascript memory.
... the incremental dom is similar to the virtual dom in that it builds a dom diff to decide what to render, but different in that it doesn't create a complete copy of the dom in javascript memory.
Advanced Svelte: Reactivity, lifecycle, accessibility - Learn web development
basically, the virtual dom is an in-memory copy of the contents of the web page.
... and, in order to avoid memory leaks, we should also call the removeeventlistener() function when the node is destroyed.
...here we will remove the listener to make sure we don't leave any memory leak behind.
Implementing feature detection - Learn web development
} property on element create an element in memory using document.createelement() and then check if a property exists on it.
...} method on element return value create an element in memory using document.createelement() and then check if a method exists on it.
... property on element retains value create an element in memory using document.createelement(), set a property to a certain value, then check to see if the value is retained.
Performance
not only does that increase memory footprint but the deserialization also has to be executed seperately for each tab, thus requiring more cpu time.
... as long as it the action does not happen frequently the memory and startup savings should outstrip the added cost of script evaluation.
...it does not provide the same memory footprint reductions but it improves application startup.
PerfMeasurement.jsm
cache_references uint64 the number of memory accesses that occurred.
... cache_misses uint64 the number of times memory accesses missed the cache.
... bus_cycles uint64 the number of memory bus cycles that elapsed.
TraceMalloc
analyzing the shutdown log the shutdown log is a basic tool for finding memory leaks.
...detecting memory usage growth in a running process to do this, dump the existing allocations to a file by calling the function tracemallocdumpallocations from javascript.
...ignore the allocations log, and run leaksoup over the memory dump (which is a dump of all allocations still live at shutdown) with a command such as ./run-mozilla.sh ./leaksoup sdleak.log > sdleak.html.
I/O Functions
functions that operate on pathnames functions that act on file descriptors directory i/o functions socket manipulation functions converting between host and network addresses memory-mapped i/o functions anonymous pipe function polling functions pollable events manipulating layers functions that operate on pathnames a file or directory in a file system is specified by its pathname.
...ewudpsocket pr_opentcpsocket pr_newtcpsocket pr_importtcpsocket pr_connect pr_connectcontinue pr_accept pr_bind pr_listen pr_shutdown pr_recv pr_send pr_recvfrom pr_sendto pr_transmitfile pr_acceptread pr_getsockname pr_getpeername pr_getsocketoption pr_setsocketoption converting between host and network addresses pr_ntohs pr_ntohl pr_htons pr_htonl pr_familyinet memory-mapped i/o functions the memory-mapped i/o functions allow sections of a file to be mapped to memory regions, allowing read-write accesses to the file to be accomplished by normal memory accesses.
... memory-mapped i/o functions are currently implemented for unix, linux, mac os x, and win32 only.
NSPR Error Handling
error type prerrorcode error functions pr_seterror pr_seterrortext pr_geterror pr_getoserror pr_geterrortextlength pr_geterrortext error codes error codes defined in prerror.h: pr_out_of_memory_error insufficient memory to perform request.
... pr_access_fault_error one of the arguments of the preceding function specified an invalid memory address.
... pr_illegal_access_error one of the arguments of the preceding function specified an invalid memory address.
PLHashAllocOps
_callback *freetable)(void *pool, void *item); plhashentry *(pr_callback *allocentry)(void *pool, const void *key); void (pr_callback *freeentry)(void *pool, plhashentry *he, pruintn flag); } plhashallocops; #define ht_free_value 0 /* just free the entry's value */ #define ht_free_entry 1 /* free value and entire entry */ description users of the hash table functions can provide their own memory allocation functions.
... the first argument, pool, for all four functions is a void * pointer that is a piece of data for the memory allocator.
... typically pool points to a memory pool used by the memory allocator.
PR_CreateFileMap
syntax #include <prio.h> prfilemap* pr_createfilemap( prfiledesc *fd, print64 size, prfilemapprotect prot); parameters the function has the following parameters: fd a pointer to a prfiledesc object representing the file that is to be mapped to memory.
... description the prfilemapprotect enumeration used in the prot parameter is defined as follows: typedef enum prfilemapprotect { pr_prot_readonly, pr_prot_readwrite, pr_prot_writecopy } prfilemapprotect; pr_createfilemap only prepares for the mapping a file to memory.
... the returned file-mapping object must be passed to pr_memmap to actually map a section of the file to memory.
PR_DELETE
allocates memory of a specified size from the heap.
... syntax #include <prmem.h> void pr_delete(_ptr); parameter _ptr the address of memory to be returned to the heap.
... description this macro returns allocated memory to the heap from the specified location and sets _ptr to null.
PR_FREEIF
conditionally frees allocated memory.
... syntax #include <prmem.h> void pr_freeif(_ptr); parameter _ptr the address of memory to be returned to the heap.
... description this macro returns memory to the heap when _ptr is not null.
PR_Free
frees allocated memory in the heap.
... syntax #include <prmem.h> void pr_free(void *ptr); parameter ptr a pointer to the memory to be freed.
... description this function frees the memory addressed by ptr in the heap.
PR_OpenAnonFileMap
size the size of the shared memory.
... prot how the shared memory is mapped.
... description if the shared memory already exists, a handle is returned to that shared memory object.
NSPR API Reference
ation and cleanup module initialization locks lock type lock functions condition variables condition variable type condition variable functions monitors monitor type monitor functions cached monitors cached monitor functions i/o types directory type file descriptor types file info types network address types types used with socket options functions type used with memory-mapped i/o offset interpretation for seek functions i/o functions functions that operate on pathnames functions that act on file descriptors directory i/o functions socket manipulation functions converting between host and network addresses memory-mapped i/o functions anonymous pipe function polling functions pollable events manipulating layers network addresses network addres...
...s types and constants network address functions atomic operations pr_atomicincrement pr_atomicdecrement pr_atomicset interval timing interval time type and constants interval functions date and time types and constants time parameter callback functions functions memory management operations memory allocation functions memory allocation macros string operations pl_strlen pl_strcpy pl_strdup pl_strfree floating point number to string conversion pr_strtod pr_dtoa pr_cnvtf long long (64-bit) integers bitmaps formatted printing linked lists linked list types prclist linked list macros pr_init_clist pr_init_static_clist pr_append_link pr_insert_link pr_next_link pr_prev_link pr_remove_link pr_remove_and_init_link...
... conditional compilation and execution log types and variables prlogmoduleinfo prlogmodulelevel nspr_log_modules nspr_log_file logging functions and macros pr_newlogmodule pr_setlogfile pr_setlogbuffering pr_logprint pr_logflush pr_log_test pr_log pr_assert pr_assert pr_not_reached use example instrumentation counters named shared memory shared memory protocol named shared memory functions anonymous shared memory anonymous memory protocol anonymous shared memory functions ipc semaphores ipc semaphore functions thread pools thread pool types thread pool functions random number generator random number generator function hash tables hash tables and type constants hash table functions nspr error hand...
NSS 3.33 release notes
in secport.h nss_securememcmpzero - check if a memory region is all zero in constant time.
... port_zallocaligned - allocate aligned memory.
... port_zallocalignedoffset - allocate aligned memory for structs.
nss tech note1
this is the arena pool from which the decoder will allocate memory as needed.
...it is only required for dynamically allocating memory for the structure if the template is being included from an asn.1 sequence or sequence of, or if dynamic allocation was requested from the parent template using the sec_asn1_pointer modifier here is a description of the various tags and modifiers that apply to the <tt style="color: rgb(0,0,0);">kind field.
... sec_asn1_pointer: similar to sec_asn1_inline, except that the memory in the target will be allocated dynamically and a pointer to the dynamically allocated memory will be stored in the dest struct at the offset.
sslfnc.html
when a new child that has been created by either createprocess or exec begins, it may have inherited file descriptors (fds), but not the parent's memory.
...the pin argument points to memory allocated by the application.
... the application is responsible for managing the memory referred to by this pointer.
SpiderMonkey compartments
compartments are used to create multiple javascript memory heaps, which avoids having one heap for all javascript objects.
...this has some important implications: all objects created by a website reside in the same compartment and hence are located in the same memory region.
...in the new model most objects touched by a website are tightly packed next to each other in memory, with no cross-origin objects in between.
Bytecode Descriptions
array literals newarray operands: (uint32_t length) stack: ⇒ array create and push a new array object with the given length, preallocating enough memory to hold that many elements.
...this single instruction implements an entire array literal, saving run time, code, and memory compared to jsop::newarray and a series of jsop::initelem instructions.
...if jsop::retsub is reached, it pops the two values (for real this time) and control resumes at the instruction that follows jsop::gosub in memory.
Exact Stack Rooting
definitions gc - acronym for garbage collection: specifically spidermonkey's method of automatically managing javascript program memory.
... cheap - the c/c++ program heap: e.g., memory allocated by malloc/calloc/realloc.
...note: spidermonkey can gc because of any error, gc because of timers, gc because we are low on memory, gc because of environment variables, gc because of cosmic rays, etc.
JSVAL_IS_INT
determine if a given jsval is a javascript number represented in memory as an integer.
... syntax jsval_is_int(v) description jsval_is_int(v) is true if the jsval v is a number represented in memory as an integer.
... to test whether a value is a number, regardless of how it is represented in memory, use jsval_is_number instead.
JS_MaybeGC
description js_maybegc tries to determine whether garbage collection in cx's runtime would free up enough memory to be worth the amount of time it would take.
...calling js_maybegc periodically when the application is busy, from a jsbranchcallback or jsoperationcallback added in spidermonkey 1.8, can keep memory usage down and improve performance.
... implementation note: spidermonkey 1.8 and earlier determine whether garbage collection is appropriate by analyzing statistics about the gc heap and memory usage since the last garbage collection cycle.
Exploitable crashes
if you see a hex address such as 0x292c2830 rather than a function name such as nslistboxbodyframe::getrowcount at the top of the stack, a bug has caused the program to transfer control to a "random" part of memory that isn't part of the program.
...the last number, in this case 0x00000000, is the memory address firefox was prevented from accessing.
... any other crash where firefox tries to use memory it does not have access to indicates some kind of memory safety bug.
Finishing the Component
getter_addrefs(catman)); if (ns_failed(rv)) return rv; char* previous = nsnull; rv = catman->addcategoryentry("xpcom-startup", "weblock", weblock_contractid, pr_true, pr_true, &previous); if (previous) nsmemory::free(previous); rv = catman->addcategoryentry("content-policy", "weblock", weblock_contractid, pr_true, pr_true, &previous); if (previous) nsmemory::free(previous); return rv; } this code adds a new category entry under the t...
... creating this many objects is ok in a tight loop if the buffer of memory that holds the contents of the urls is guaranteed to be valid for the lifetime of the object.
... but regardless of how optimized the implementation is with respect to is memory usage, a heap allocation will be made for every xpcom object created.
Core XPCOM functions
xpcom provides a number of global functions which are used to initialize and shut down the xpcom library, as well as to allocate memory, get access to services, and to instantiate interfaces.
... ns_allocinfallibly allocates a block of memory using the xpcom memory manager.ns_freefrees a block of memory using the xpcom memory manager.ns_getcomponentmanagerthe ns_getcomponentmanager function returns a reference to the xpcom component manager.ns_getcomponentregistrarthe ns_getcomponentregistrar function returns a reference to the xpcom component registrar.ns_getmemorymanagerthe ns_getmemorymanager function returns a reference to the xpcom memory manager.ns_getservicemanagerthe ns_getservicemanager function returns a reference to the xpcom service manager.ns_initxpcom2the ns_initxpcom2 function initiates use of xpcom in the calling process.ns_initxpcom3the ns_initxpcom3 function initiates use of xpcom in the calling process with support for statically defined xpcom modules.
... ns_newlocalfilethe ns_newlocalfile function creates an instance of nsilocalfile that provides a platform independent representation of a file path.ns_newnativelocalfilethe ns_newnativelocalfile function creates an instance of nsilocalfile that provides a platform independent representation of a file path.ns_reallocreallocates a block of memory using the xpcom memory manager.ns_shutdownxpcomthe ns_shutdownxpcom function terminates use of xpcom in the calling process.nsresultthe nsresult data type is a strongly-typed enum used to represent a value returned by an xpcom function; these are typically error or status codes.
mozIStorageFunction
function : public mozistoragefunction { public: ns_imethod onfunctioncall(mozistoragevaluearray *aarguments, nsivariant **_result) { print32 value; nsresult rv = aarguments->getint32(&value); ns_ensure_success(rv, rv); nscomptr<nsiwritablevariant> result = do_createinstance("@mozilla.org/variant;1"); ns_ensure_true(result, ns_error_out_of_memory); rv = result->setasint64(value * value); ns_ensure_success(rv, rv); ns_addref(*_result = result); return ns_ok; } }; // now, register our function with the database connection.
... nscomptr<mozistoragefunction> func = new squarefunction(); ns_ensure_true(func, ns_error_out_of_memory); nsresult rv = dbconn->createfunction( ns_literal_cstring("square"), 1, func ); ns_ensure_success(rv, rv); // run some query that uses the function.
...mozistoragestatement> stmt; rv = dbconn->createstatement(ns_literal_cstring( "select square(value) from some_table"), getter_addrefs(stmt) ); ns_ensure_success(rv, rv); prbool hasmore; while (ns_succeeded(stmt->executestep(&hasmore)) && hasmore) { // handle the results } see also storage introduction and how-to article mozistorageconnection database connection to a specific file or in-memory data storage mozistoragestatement create and execute sql statements on a sqlite database.
mozIStorageService
ns_error_out_of_memory allocating a new storage object failed.
...valid values are "profile" and "memory".
... ns_error_out_of_memory allocating a new storage object failed.
nsIContentPrefService2
getcachedbydomainandname() synchronously retrieves from the in-memory cache the preference with the given domain and name.
...getcachedbysubdomainandname() synchronously retrieves from the in-memory cache all preferences with the given name whose domains are either the same as or subdomains of the given domain.
... getcachedglobal() synchronously retrieves from the in-memory cache the preference with no domain and the given name.
nsIPipe
inherits from: nsisupports last changed in gecko 1.6 method overview void init(in boolean nonblockinginput, in boolean nonblockingoutput, in unsigned long segmentsize, in unsigned long segmentcount, in nsimemory segmentallocator); attributes attribute type description inputstream nsiasyncinputstream the pipe's input end, which also implements nsisearchableinputstream.
...void init( in boolean nonblockinginput, in boolean nonblockingoutput, in unsigned long segmentsize, in unsigned long segmentcount, in nsimemory segmentallocator ); parameters nonblockinginput true specifies non-blocking input stream behavior.
... segmentallocator pass reference to nsimemory to have all pipe allocations use this allocator (pass null to use the default allocator) remarks the reader and writer of a pipe do not have to be on the same thread.
nsIToolkitProfileService
ns_error_out_of_memory unable to allocate the new profile object.
...the profile list file is constructed in memory, then written out as one large chunk, in order to reduce the risk of the profile list file being corrupted by disk errors.
...exceptions thrown ns_error_out_of_memory an error occurred trying to allocate the memory buffer used to construct the profile list.
Testing Mozilla code
the first part will focus on the modern and robust way of static-analysis and the second part will present the build-time static-analysis.debugging mozilla with valgrindthis page describes how to use valgrind (specifically, its memcheck tool) to find memory errors.firefox and address sanitizeraddress sanitizer (asan) is a fast memory error detector that detects use-after-free and out-of-bound bugs in c/c++ programs.
...in addition, the runtime part replaces the malloc and free functions to check dynamically allocated memory.
...this type of coverage is only concerned with hit counts for lines and branches.the valgrind test jobthe valgrind test job builds the browser and runs it under valgrind, which can detect various common memory-related errors.
Working with data
sted.addressofelement(1).contents; // this outputs `2` mycasted.addressofelement(1).contents.tostring(); // outputs: `"2"` source of this, and to see wrong ways of casting, and explanation on why this is the right way to cast an array (explained by matching constructor's) see here: githubgist :: _ff-addon-tutorial-jsctypes_castingarrays data and pointers a cdata object represents a c value in memory.
... objects can share memory it's important to keep in mind that two (or more) cdata objects can share the same memory block for their contents.
...the shared memory can be whole or in part.
Browser Side Plug-in API - Plugins
npn_memalloc allocates memory from the browser's memory space.
... npn_memflush requests that the browser free a specified amount of memory.
... npn_memfree deallocates a block of allocated memory.
Streams - Plugins
npres_network_err: the stream failed because of problems with the network, disk i/o error, lack of memory, or some other problem.
...if the plug-in allocates memory for the entire stream at once, it can return a large number.
...typically, the only streams that are seekable are from data that is in memory or on the disk, or from http servers that support byte-range requests.
Tutorial: Show Allocations Per Call Path - Firefox Developer Tools
var dbg; // start measuring the selected tab's main window's memory // consumption.
... dbg.memory.trackingallocationsites = true; } window.demoplotallocations = function() { // grab the allocation log.
... var log = dbg.memory.drainallocationslog(); // neutralize the debugger, and drop it on the floor // for the gc to collect.
Tree map view - Firefox Developer Tools
the tree map view provides a visual representation of the snapshot, that helps you quickly get an idea of which objects are using the most memory.
... for the treemaps shown in the memory tool, things on the heap are divided at the top level into four categories: objects: javascript and dom objects, such as function, object, or array, and dom types like window and htmldivelement.
...this means you can quickly get an idea of roughly what sorts of things allocated by your site are using the most memory.
HTMLCanvasElement.mozGetAsFile() - Web APIs
the non-standard, firefox-specific the htmlcanvaselement method mozgetasfile() returns a memory-based file object representing the image contained in the canvas.
... syntax canvas.mozgetasfile(name, type); parameters name a domstring indicating the file name to give the file representing the image file in memory.
...the file's data is entirely located in memory until such time as it is explicitly written to disk.
URL.createObjectURL() - Web APIs
note: this feature is not available in service workers due to its potential to create memory leaks.
... usage notes memory management each time you call createobjecturl(), a new object url is created, even if you've already created one for the same object.
... browsers will release object urls automatically when the document is unloaded; however, for optimal performance and memory usage, if there are safe times when you can explicitly unload them, you should do so.
WebGLRenderingContext.vertexAttribPointer() - Web APIs
usually, your 3d geometry is already in a certain binary format, so you need to read the specification of that specific format to figure out the memory layout.
... however, if you are designing the format yourself, or your geometry is in text files (like wavefront .obj files) and must be converted into an arraybuffer at runtime, you have free choice on how to structure the memory.
... = await fetch('assets/geometry.bin'); const buffer = await response.arraybuffer(); consume array buffer with webgl first, we create a new vertex buffer object (vbo) and supply it with our array buffer: //bind array buffer to a vertex buffer object const vbo = gl.createbuffer(); gl.bindbuffer(gl.array_buffer, vbo); gl.bufferdata(gl.array_buffer, buffer, gl.static_draw); then, we specify the memory layout of the array buffer, either by setting the index ourselves: //describe the layout of the buffer: //1.
Content negotiation - HTTP
the device-memory value is in chrome 61 or later.
...valid values are: value meaning device-memory indicates the approximate amount of device ram.
... the accept-ch-lifetime header is used with the device-memory value of the accept-ch header and indicates the amount of time the device should opt-in to sharing the amount of device memory with the server.
Inheritance and the prototype chain - JavaScript
making your javascript run fast is completely out of the question if you dare use this in the final production code because many browsers optimize the prototype and try to guess the location of the method in the memory when calling an instance in advance, but setting the prototype dynamically disrupts all these optimizations and can even force some browsers to recompile for deoptimization your code just to make it work according to the specs.
...making your javascript run fast is completely out of the question if you dare use this in the final production code because many browsers optimize the prototype and try to guess the location of the method in the memory when calling an instance in advance, but setting the prototype dynamically disrupts all these optimizations and can even force some browsers to recompile for deoptimization your code just to make it work according to the specs.
...for example, when you do var a1 = new a(), javascript (after creating the object in memory and before running function a() with this defined to it) sets a1.[[prototype]] = a.prototype.
TypedArray - JavaScript
int8array), an array buffer is created internally in memory or, if an arraybuffer object is given as constructor argument, then this is used instead.
... parameters length when called with a length argument, an internal array buffer is created in memory, of size length multiplied by bytes_per_element bytes, containing zeros.
...the byteoffset and length parameters specify the memory range that will be exposed by the typed array view.
WeakRef - JavaScript
in contrast, a normal (or strong) reference keeps an object in memory.
... when an object no longer has any strong references to it, the javascript engine's garbage collector may destroy the object and reclaim its memory.
... various runtime heuristics can be used to balance memory usage, responsiveness.
WebAssembly - JavaScript
creating new memory and table instances via the webassembly.memory()/webassembly.table() constructors.
... webassembly.memory() an object whose buffer property is a resizable arraybuffer that holds the raw bytes of memory accessed by a webassembly instance.
... 52notes notes disabled in the firefox 52 extended support release (esr).opera android full support 43safari ios full support 11samsung internet android full support 7.0nodejs full support 8.0.0memorychrome full support 57edge full support 16firefox full support 52notes full support 52notes notes disabled in the firefox 52 extended support release (esr).ie no support noop...
delete operator - JavaScript
description unlike what common belief suggests (perhaps due to other programming languages like delete in c++), the delete operator has nothing to do with directly freeing memory.
... memory management is done indirectly via breaking references.
... see the memory management page for more details.
JavaScript typed arrays - JavaScript
javascript typed arrays are array-like objects that provide a mechanism for reading and writing raw binary data in memory buffers.
...in order to access the memory contained in a buffer, you need to use a view.
... examples using views with buffers first of all, we will need to create a buffer, here with a fixed length of 16-bytes: let buffer = new arraybuffer(16); at this point, we have a chunk of memory whose bytes are all pre-initialized to 0.
Digital audio concepts - Web media technologies
that means each sample requires 32 bits of memory.
... at the common sample rate of 48 khz (48,000 samples per second), this means each second of audio occupies 192 kb of memory.
... therefore, a typical three-minute song requires about 34.5 mb of memory.
JavaScript/XSLT Bindings - XSLT: Extensible Stylesheet Language Transformations
to process part of a page's dom, it is necessary to first create an xml document in memory.
... assuming that the dom to be processed is contained by an element with the id example, that dom can be "cloned" using the in-memory xml document's document.importnode() method.
... figure 2 : creating an xml document based on part of a document's dom // create a new xml document in memory var xmlref = document.implementation.createdocument("", "", null); // we want to move a part of the dom from an html document to an xml document.
Index - WebAssembly
8 index index, webassembly found 12 pages: 9 loading and running webassembly code fetch, javascript, webassembly, xmlhttprequest, bytecode to use webassembly in javascript, you first need to pull your module into memory before compilation/instantiation.
... 10 understanding webassembly text format functions, javascript, s-expressions, webassembly, calls, memory, shared address, table, text format, was, wasm this finishes our high-level tour of the major components of the webassembly text format and how they get reflected in the webassembly js api.
... 11 using the webassembly javascript api api, devtools, javascript, webassembly, compile, instantiate, memory, table this article has taken you through the basics of using the webassembly javascript api to include a webassembly module in a javascript context and make use of its functions, and how to use webassembly memory and tables in javascript.
Modules - Archive of obsolete content
a compartment is a separate memory space.
...compartments are a fairly recent addition to spidermonkey, and can be seen as a separate memory space.
page-worker - Archive of obsolete content
a page worker may be destroyed, after which its memory is freed, and you must create a new instance to load another page.
...after you destroy a page worker, its memory is freed and you must create a new instance if you need to load another page.
cfx - Archive of obsolete content
--check-memory attempts to detect leaked compartments after a test run.
... --profile-memory=profilememory if this option is given and profilememory is any non-zero integer, then cfx dumps detailed memory usage information to the console when the tests finish.
Jetpack Processes - Archive of obsolete content
if that other process does not do something explicit and simply removes all references to it, the handle remains rooted yet unreachable in both processes and a memory leak is created.
... to prevent such memory leaks, a process can either invalidate a handle, immediately preventing it from being passed as a message argument, or it can unroot the handle, allowing it to be passed as a message argument until all references to it are removed, at which point it is garbage collected.
Using content preferences - Archive of obsolete content
because of this, in private browsing mode, use of the content preference service needed to be avoided while in private browsing mode; instead, information needed to be stored in memory or preferences had to be avoided.
... starting in gecko 9.0, when in private browsing mode, the content preference service stores preferences in memory instead of on disk, and automatically forgets them when leaving private browsing mode.
Style System Overview - Archive of obsolete content
text-indent: 0; } cssstyleruleimpl cssstyleruleimpl ↓ ↓ ↓ ↓ h1 nscssdeclaration h2 ↙ ↘ nscsscolor — color: green nscsstext — text-align: right text-indent: 0 css style rule representation problem: the rule structures use too much memory (a few hundred kilobytes for all our chrome), and require large numbers of allocations to construct.
... some style data is cached on nsrulenode objects to speed up computation and reduce memory use.
Message Summary Database - Archive of obsolete content
mork loads the whole database in memory, and keeps it there.
... this makes it very fast to access our database objects, but it does increase memory usage.
Migrate apps from Internet Explorer to Mozilla - Archive of obsolete content
document fragments for performance reasons, you can create documents in memory, rather than working on the existing document's dom.
... <xsl:if test="system-property('xsl:vendor') = 'transformiix'"> <!-- mozilla specific markup --> </xsl:if> <xsl:if test="system-property('xsl:vendor') = 'microsoft'"> <!-- internet explorer specific markup --> </xsl:if> mozilla also provides javascript interfaces for xslt, allowing a web site to complete xslt transformations in memory.
Prism - Archive of obsolete content
benefits separate process: web apps can hog memory or processor cycles or even bring down the whole browser in extreme cases.
...we can also benefit from operating system tools that lets us view the memory/cpu consumption of a specific application.
Actionscript Performance Tests - Archive of obsolete content
use the --memory flag to capture the maximum private bytes memory (high water mark) for a test.
...# to measure memory $ ./runtests.py --memory sunspider/*.as test avm metric sunspider/access-binary-trees.as 2.4m memory sunspider/access-fannkuch.as 1.5m memory ...
Using gdb on wimpy computers - Archive of obsolete content
the debugger uses a lot of memory.
...if your computer has less than 256 mb of memory, your computer will become unhappy as gdb loads mozilla's shared libraries.
The Implementation of the Application Object Model - Archive of obsolete content
"couldn't you just perform a tree transformation on whatever representation you have in memory?" the answer is "yes, provided there is one single common intermediate representation of the collected and aggregated data to use as the basis for the translation." "why?" you ask.
...a xul document is read into gecko's parser, and a specialized content sink, known as the xul content sink, is responsible for constructing the in-memory rdf graph representation of the xul.
Archived Mozilla and build documentation - Archive of obsolete content
the contents of this standalone xpcom in general are: stress testing consume.exe from the windows server 2003 resource kit tools can consume various resources: physical memory, cpu time, page file, disk space and even the kernel pool.
... the life of an html http request the new nsstring class implementation (1999) this document is intended to briefly describe the new nsstring class architecture, and discuss the implications on memory management, optimizations, internationalization and usage patterns.
2006-11-17 - Archive of obsolete content
boaz invites your comments xulrunner 1.8.0.4 is running a kiosk-type application on linux with 512mb, and there is the appearance of a significant memory leak.
... win2xul asks for any quick pointers, opinions, experience, suggestions or ideas on where xulrunner might leak memory bug 319654 was fixed on trunk recently.
NPAPI plugin developer guide - Archive of obsolete content
plug-in display modes using the object element for plug-in display nesting rules for html elements using the appropriate attributes using the embed element for plug-in display using custom embed attributes plug-in references plug-in development overview writing plug-ins registering plug-ins ms windows unix mac os x drawing a plug-in instance handling memory sending and receiving streams working with urls getting version and ui information displaying messages on the status line making plug-ins scriptable building plug-ins building, platforms, and compilers building carbonized plug-ins for mac os x type libraries installing plug-ins native installers xpi plug-ins installations plug-in installation and the windows...
... stream to the plug-in sending the stream in random-access mode sending the stream in file mode sending a stream creating a stream pushing data into the stream deleting the stream example of sending a stream urls getting urls getting the url and displaying the page posting urls posting data to an http server uploading files to an ftp server sending mail memory allocating and freeing memory mac os flushing memory (mac os only) version, ui, and status information displaying a status line message getting agent information getting the current version finding out if a feature exists reloading a plug-in ...
NP_Initialize - Archive of obsolete content
allocate any memory or resources shared by all instances of your plug-in at this time.
... after the last instance of a plug-in has been deleted, the browser calls np_shutdown, where you can release allocated memory or resources.
NP_Shutdown - Archive of obsolete content
if you have defined a java class for your plug-in, be sure to release it at this time so that java can unload it and free up memory.
... note: if enough memory is available, the browser can keep the plug-in library loaded if it expects to create more instances in the near future.
Common Firefox theme issues and solutions - Archive of obsolete content
to accomplish this copy the file chrome://mozapps/skin/extensions/extensions.svg from the default theme into the mozapps/extensions/ folder of your theme and add the following style rule to the css file extensions.css: .addon[active="false"] .icon { filter: url("chrome://mozapps/skin/extensions/extensions.svg#greyscale"); opacity:0.3; } about:memory about:memory nodes do not collapse the styling of about:memory is a little messed up in that nodes do not collapse as they should when clicked on.
... to fix this issue you need to copy the following file from the latest version of firefox to your theme: chrome://global/content/aboutmemory.css.
Using IO Timeout And Interrupt On NT - Archive of obsolete content
if the thread subsequently exists and its <tt>prthread</tt> structure gets deleted, the pointer to the overlapped buffer will be pointing to freed memory.
...the first <tt>pr_close()</tt> would succeed, but the second <tt>pr_close()</tt> would be freeing freed memory.
ArrayBuffer.transfer() - Archive of obsolete content
the ability to detach an arraybuffer gives the developer explicit control over when the underlying memory is released.
...this is not the exact equivalent of this api because browsers that natively support it are be able to internally use the c++ function realloc() which extends the length of the memory and only copies it to a new location as-needed as opposed to the following pollyfill which always copies the whole thing to a new space of memory, but this function transfers data from one arraybuffer to another arraybuffer.
Generator comprehensions - Archive of obsolete content
a significant drawback of array comprehensions is that they cause an entire new array to be constructed in memory.
...an array comprehension would create a full array in memory containing the doubled values: var doubles = [for (i in it) i * 2]; a generator comprehension on the other hand would create a new iterator which would create doubled values on demand as they were needed: var it2 = (for (i in it) i * 2); console.log(it2.next()); // the first value from it, doubled console.log(it2.next()); // the second value from it, doubled when a generator comprehension i...
Windows Media in Netscape - Archive of obsolete content
window.activexobject) { req = new activexobject("microsoft.xmlhttp"); } else if (window.xmlhttprequest) { req = new xmlhttprequest(); } // req can be used in a cross-browser way -- the actual objects are similar // caveat emptor: look out for the case of methods and properties -- ie uses // capital letters where gecko uses lowercase other popular uses of microsoft's msxml objects are for in-memory manipulation of xml documents via xslt, perhaps to construct dynamic data for the windows media player.
... netscape gecko based browsers such as netscape 7.1 provide comparable implementations of xslt transformations in memory via javascript.
Hoisting - MDN Web Docs Glossary: Definitions of Web-related terms
instead, the variable and function declarations are put into memory during the compile phase, but stay exactly where you typed them in your code.
... learn more technical example one of the advantages of javascript putting function declarations into memory before it executes any code segment is that it allows you to use a function before you declare it in your code.
Index - MDN Web Docs Glossary: Definitions of Web-related terms
in sisd architecture, a single processor executes a single instruction and operates on a single data point in memory.
... 516 buffer buffer, codingscripting, glossary, needscontent a buffer is a storage in physical memory used to temporarily store data while it is being transferred from one place to another.
Mutable - MDN Web Docs Glossary: Definitions of Web-related terms
(you can make a variable name point to a new value, but the previous value is still held in memory.
... on appending the "immutablestring" with a string value, following events occur: existing value of "immutablestring" is retrieved "world" is appended to the existing value of "immutablestring" the resultant value is then allocated to a new block of memory "immutablestring" object now points to the newly created memory space previously created memory space is now available for garbage collection.
Multimedia: Images - Learn web development
you also need to be considerate of memory as many mobile devices have limited ram.
... it's important to remember that when images are downloaded, they need to be stored in memory.
Getting started with Svelte - Learn web development
less code means less kb to download, parse, execute, and keep hanging around in memory.
...this is executable code that needs to be parsed, executed, and kept in memory.
Focus management with Vue refs - Learn web development
this means that vue keeps a representation of all of the nodes in our app in memory.
... any updates are first performed on the in-memory nodes, and then all the changes that need to be made to the actual nodes on the page are synced in a batch.
Gecko info for Windows accessibility vendors
avoiding memory leaks it is the assistive technology's responsibility to watch for system events that indicate when windows are being destroyed, and to release all iaccessibles related to that window.
... to help web developers in that regard, there is the wonderful memory leak monitor, a firefox 1.5+ extension from david baron, which warns chrome and extension developers about one particular type of memory leak.
Debugging a hang on OS X (Archived)
note that sampling will quickly hog up a lot of memory if you leave it on for too long!
...note that only 3-4 seconds usually suffice, note that this will quickly hog up a lot of memory if you leave it on for too long!
Debugging
debugging mozilla with valgrind valgrind is a memory debugger for mac and linux.
... it is slow, but good for tracking down difficult memory safety bugs.
Simple SeaMonkey build
minimum and recommended hardware requirements for mozilla development are: recommended: 8gb of ram (having only 4gb ram and 4gb swap may give memory errors during compile) 35 gb free disk space.
... mk_add_options moz_objdir=/path/to/comm-central/obj-sm-debug ac_add_options --enable-application=suite ac_add_options --enable-debug ac_add_options --disable-optimize normally a shared build suffices for debugging purposes but current nightly releases are actually static builds which require even more memory to link.
Performance best practices for Firefox front-end engineers
sometimes this can be addressed by ensuring that the thing changing is on its own layer (though this comes at a memory cost).
... a documentfragment is maintained in memory outside the dom itself, so changes don't cause reflow.
Firefox and the "about" protocol
here is a complete list of urls in the about: pseudo protocol: about: page description about:about provides an overview of all about: pages available for your current firefox version about:addons add-ons manager about:buildconfig displays the configuration and platform used to build firefox about:cache displays information about the memory, disk, and appcache about:checkerboard switches to the checkerboarding measurement page, which allows to detect checkerboarding issues about:config provides a way to inspect and change firefox preferences and settings about:compat lists overriding site compatability fixes, linked to specific bug issues.
...o debug add-ons, tabs and service workers about:devtools summarizes the developer tools and provides links to documentation for each tool about:downloads displays all downloads done within firefox about:home start page of firefox when opening a new window about:license displays licensing information about:logo firefox logo about:memory provides a way to display memory usage, save it as report and run the gc and cc about:mozilla special page showing a message from "the book of mozilla" about:networking displays networking information about:newtab start page when opening a new tab about:performance displays memory and performance information about firefox subprocesses/add-ons/tab...
Script security
a compartment is a specific, separate area of memory.
...this means that each global object and the objects associated with it live in their own region of memory.
How to get a process dump with Windows Task Manager
(to get a process dump for thunderbird or some other product, substitute the product name where ever you see firefox in these instructions.) caution the memory dump that will be created through this process is a complete snapshot of the state of firefox when you create the file, so it contains urls of active tabs, history information, and possibly even passwords depending on what you are doing when the snapshot is taken.
... it is advisable to create a new, blank profile to use when reproducing the hang and capturing the memory dump.
IPDL Best Practices
do not use them as data structures outside of ipdl, or wou will eventually find yourself in bad situations to implement proper memory management.
... a good example of this problem is the amount of memory management bugs that we have had with using surfacedescriptor directly everywhere.
Localizing with Pontoon
translation helpers as you can see, suggestions from history, translation memory, machine translation and other locales are also available in the out-of-context translation panel.
... machinery displays matches from various services: internal translation memory, mozilla transvision, open source translation memory, microsoft terminology and machine translation.
Mozilla Style System
the barrier between these two halves consists of three abstract interfaces, plus some smaller structures associated with some methods on each: nsistylesheet nsistylesheet represents what one would think of as a style sheet: the in-memory representation of a css file or other source of style data.
...however, the second of these rules is the key to many of the performance and memory-use optimizations in the style system.
Mozilla Style System Documentation
this double tree (style context tree and rule tree) allows for sharing of style data, which allows the data to take up less memory and allows the data computation to take less time.
...i'm reluctant to write it both since i don't know much about it.] problems:a bunch the code needs to be rewritten to prevent stylesheets from blocking the parser and to reduce string copying (although that partly goes with parsing).] parsing stylesheet representation problems: the stylesheet representation uses way too much memory.
Leak-hunting strategies and tips
mac any build leak tools for debugging memory growth that is cleaned up on shutdown diffbloatdump (part of tracemalloc) all allocations linux only?
...some places you can do this are: layout engine define debug_tracemalloc_framearena where it is commented out in layout/base/nspresshell.cpp glib set the environment variable g_slice=always-malloc other references performance tools leak debugging screencasts (dbaron) leakingpages - a list of pages known to leak mdc:performance - contains documentation for all of our memory profiling and leak detection tools ...
Power profiling overview
it includes various components including the l3 cache, memory controller, and, for processors that have one, the integrated gpu.
... pp1: an uncore device, usually the gpu (not available on all processor models.) dram: main memory (not available on all processor models.) the following relationship holds: pp0 + pp1 <= pkg.
Profiling with Instruments
instruments can be used for memory profiling and for statistical profiling.
... memory profiling instruments will record a call stack at each allocation point.
Profiling with Xperf
for 64-bit windows 7 or vista, you'll need to do a registry tweak and then restart to enable stack walking: reg add "hklm\system\currentcontrolset\control\session manager\memory management" -v disablepagingexecutive -d 0x1 -t reg_dword -f symbol server setup with the latest versions of the windows performance toolkit, you can modify the symbol path directly from within the program via the trace menu.
...the stock windows crt allocator is horrible about fragmentation, and causes memory usage to rise drastically even if only a small fraction of that memory is in use.
Preference reference
the xul cache is serialized and saved between mozilla sessions in the xul fastload file, which saves a “compiled” version of the xul and javascript in a document to disk for faster startup the next time the application runs.reader.parse-on-load.force-enabledthe preference reader.parse-on-load.force-enabled controls if the reader mode used in firefox mobile should be enabled independent of the memory available in the device.
... by default, the reader mode in firefox mobile is only enabled if the memory is greater than 384mb.ui.alertnotificationoriginui.alertnotificationorigin controls the position and direction from which popup notifications invoked by nsialertsservice are sliding in.ui.spellcheckerunderlineui.spellcheckerunderline holds the colour which is used to underline words not recognized by the spellchecker.ui.spellcheckerunderlinestyleui.spellcheckerunderlinestyle holds the style which is used to underline words not recognized by the spellchecker.ui.textselectbackgroundui.textselectbackground saves the color in which the background of a text selection in the user interface or in content will be styled.ui.textselectforegroundui.textselectforeground saves the color in which the text of a text selection in the u...
Emscripten techniques
debugging out-of-memory problems a common bug to diagnose with emscripten is where a big game fails due to an out of memory error (oom) somewhere during load time.
... by the time about:memory is loaded in a new tab and you have clicked the "measure" button to diagnose what's happened, the memory usage causing the spike has gone away, making temporary memory spikes difficult to diagnose.
About NSPR
these facilities include threads, thread synchronization, normal file and network i/o, interval timing and calendar time, basic memory management (malloc and free) and shared library linking.
... memory management nspr provides api to perform the basic malloc, calloc, realloc and free functions.
I/O Types
directory type file descriptor types file info types network address types types used with socket options functions type used with memory-mapped i/o offset interpretation for seek functions directory type prdir file descriptor types nspr represents i/o objects, such as open files and sockets, by file descriptors of type prfiledesc.
... file info types prfileinfo prfileinfo64 prfiletype network address types prnetaddr pripv6addr types used with socket options functions prsocketoptiondata prsockoption prlinger prmcastrequest type used with memory-mapped i/o prfilemap offset interpretation for seek functions prseekwhence ...
PR_AtomicIncrement
the result of the function is the value of the memory after the operation.
... the writing of the memory is unconditional.
PR_AtomicSet
the returned value is the value that was readbefore memory was updated.
... the memory modification is unconditional--that is, it isn't a test and set operation.
PR_CloseFileMap
returns the function returns one of the following values: if the memory region is successfully unmapped, pr_success.
... if the memory region is not successfully unmapped, pr_failure.
PR_NEW
allocates memory of a specified size from the heap.
... description this macro allocates memory whose size is sizeof(_struct) and returns a pointer to that memory.
PR_NEWZAP
allocates and clears memory from the heap for an instance of a given type.
... description this macro allocates an instance of the specified type from the heap and sets the content of that memory to zero.
NSS_3.12.1_release_notes.html
form of cert_nametoascii bug 390296: nss ignores subject cn even when san contains no dnsname bug 401928: support generalized pkcs#5 v2 pbes bug 403543: pkix: need a way to enable/disable aia cert fetching bug 408847: pkix_ocspchecker_check does not support specified responder (and given signercert) bug 414003: crash [[@ cert_decodecertpackage] sometimes with this testcase bug 415167: memory leak in certutil bug 417399: arena allocation results are not checked in pkix_pl_infoaccess_parselocation bug 420644: improve ssl tracing of key derivation bug 426886: use const char* in pk11_importcertforkey bug 428103: cert_encodesubjectkeyid is not defined in any public header file bug 429716: debug builds of libpkix unconditionally dump socket traffic to stdout bug 430368: vfychai...
... bug 430916: add sustaining asserts bug 431805: leak in nssarena_destroy() bug 431929: memory leaks on error paths in devutil.c bug 432303: replace pkix_pl_memcpy with memcpy bug 433177: fix the gcc compiler warnings in lib/util and lib/freebl bug 433437: vfychain ignores the -a option bug 433594: crash destroying ocsp cert id [[@ cert_destroyocspcertid ] bug 434099: nss relies on unchecked pkcs#11 object attribute values bug 434187: fix the gcc compiler warnings in nss/lib ...
NSS_3.12.2_release_notes.html
bug 456854: cert_decodecertpackage does not set nspr error code upon error bug 457980: hundreds of kilobytes of useless strings in libpkix bug 457984: enable pkcs11 module logging in optimized builds bug 458905: memory leaks in pkix bridge certificates.
... bug 459231: memory leak in cert fetching - aia extension.
NSS 3.19.2.1 release notes
bug 1205157 (nspr, cve-2015-7183): a logic bug in the handling of large allocations would allow exceptionally large allocations to be reported as successful, without actually allocating the requested memory.
... this may allow attackers to bypass security checks and obtain control of arbitrary memory.
NSS 3.19.4 release notes
bug 1205157 (nspr, cve-2015-7183): a logic bug in the handling of large allocations would allow exceptionally large allocations to be reported as successful, without actually allocating the requested memory.
... this may allow attackers to bypass security checks and obtain control of arbitrary memory.
NSS 3.20.1 release notes
bug 1205157 (nspr, cve-2015-7183): a logic bug in the handling of large allocations would allow exceptionally large allocations to be reported as successful, without actually allocating the requested memory.
... this may allow attackers to bypass security checks and obtain control of arbitrary memory.
NSS 3.27.2 Release Notes
this is a patch release to address a memory leak in the ssl_settrustanchors() function.
... previous versions of nss leaked the memory used to store distinguished names when ssl_settrustanchors() was used.
NSS 3.48 release notes
implementation for hmac and cmac behind pkcs#11 bug 1522203 - remove an old pentium pro performance workaround bug 1592557 - fix prng known-answer-test scripts bug 1586176 - encryptupdate should use maxout not block size (cve-2019-11745) bug 1593141 - add `notbefore` or similar "beginning-of-validity-period" parameter to mozilla::pkix::trustdomain::checkrevocation bug 1591363 - fix a pbkdf2 memory leak in nsc_generatekey if key length > max_key_len (256) bug 1592869 - use arm neon for ctr_xor bug 1566131 - ensure sha-1 fallback disabled in tls 1.2 bug 1577803 - mark pkcs#11 token as friendly if it implements ckp_public_certificates_token bug 1566126 - power ghash vector acceleration bug 1589073 - use of new pr_assert_arg in certdb.c bug 1590495 - fix a crash in pk11_makecertfromhandl...
...td=gnu99 bug 1590676 - fix build if arm doesn't support neon bug 1575411 - enable tls extended master secret by default bug 1590970 - ssl_settimefunc has incomplete coverage bug 1590678 - remove -wmaybe-uninitialized warning in tls13esni.c bug 1588244 - nss changes for delegated credential key strength checks bug 1459141 - add more cbc padding tests that missed nss 3.47 bug 1590339 - fix a memory leak in btoa.c bug 1589810 - fix uninitialized variable warnings from certdata.perl bug 1573118 - enable tls 1.3 by default in nss this bugzilla query returns all the bugs fixed in nss 3.48: https://bugzilla.mozilla.org/buglist.cgi?resolution=fixed&classification=components&query_format=advanced&product=nss&target_milestone=3.48 compatibility nss 3.48 shared libraries are backward compatib...
Enc Dec MAC Output Public Key as CSR
e 'g': return gen_csr; case 'e': return encrypt; case 'd': return decrypt; default: return unknown; } } /* * wrap the symkey using public key */ secstatus wrapkey(pk11symkey* key, seckeypublickey *pubkey, secitem **wrappedkey) { secstatus rv; secitem *data = (secitem *)port_zalloc(sizeof(secitem)); if (!data) { pr_fprintf(pr_stderr, "error while allocating memory\n"); rv = secfailure; goto cleanup; } data->len = seckey_publickeystrength(pubkey); data->data = (unsigned char*)port_zalloc((data->len)*sizeof(unsigned int)); if (!data->data) { pr_fprintf(pr_stderr, "error while allocating memory\n"); rv = secfailure; goto cleanup; } rv = pk11_pubwrapsymkey(ckm_rsa_pkcs, pubkey, key, data); ...
...\n"); rv = secfailure; goto cleanup; } /* generate certificate request */ cr = cert_createcertificaterequest(subject, spki, null); if (!cr) { pr_fprintf(pr_stderr, "unable to make certificate request\n"); rv = secfailure; goto cleanup; } arena = port_newarena(der_default_chunksize); if (!arena) { fprintf(stderr, "out of memory"); rv = secfailure; goto cleanup; } exthandle = cert_startcertificaterequestattributes(cr); if (exthandle == null) { port_freearena (arena, pr_false); rv = secfailure; goto cleanup; } cert_finishextensions(exthandle); cert_finishcertificaterequestattributes(cr); /* der encode the request */ encoding = sec_asn1encodeitem(ar...
FC_Initialize
(note: we probably should return ckr_host_memory instead.) the software integrity test or power-up self-tests failed.
... ckr_host_memory: we ran out of memory.
NSS Key Functions
when an application makes a copy of a particular certificate or key structure that already exists in memory, ssl makes a shallow copy--that is, it increments the reference count for that object rather than making a whole new copy.
... when you call cert_destroycertificate or seckey_destroyprivatekey, the function decrements the reference count and, if the reference count reaches zero as a result, both frees the memory and sets all the bits to zero.
OLD SSL Reference
up the server db and certificate setting up the client db and certificate verifying the server and client certificates building nss programs chapter 3 selected ssl types and structures this chapter describes some of the most important types and structures used with the functions described in the rest of this document, and how to manage the memory used for them.
... types and structures certcertdbhandle certcertificate pk11slotinfo secitem seckeyprivatekey secstatus managing secitem memory secitem_freeitem secitem_zfreeitem chapter 4 ssl functions this chapter describes the core ssl functions.
sslcrt.html
when an application makes a copy of a particular certificate or key structure that already exists in memory, ssl makes a shallow copy--that is, it increments the reference count for that object rather than making a whole new copy.
... when you call cert_destroycertificate or seckey_destroyprivatekey, the function decrements the reference count and, if the reference count reaches zero as a result, both frees the memory and sets all the bits to zero.
sslerr.html
these failures may be caused by the system running out of memory, or errors returned by pkcs#11 routines that did not provide meaningful error codes of their own.
... sec_error_no_memory -8173 security library: memory allocation failure.
sslkey.html
when an application makes a copy of a particular certificate or key structure that already exists in memory, ssl makes a shallow copy--that is, it increments the reference count for that object rather than making a whole new copy.
... when you call cert_destroycertificate or seckey_destroyprivatekey, the function decrements the reference count and, if the reference count reaches zero as a result, both frees the memory and sets all the bits to zero.
TLS Cipher Suite Discovery
this function is declared in "ssl.h" as follows: ssl_import secstatus ssl_getciphersuiteinfo( pruint16 ciphersuite, sslciphersuiteinfo *info, pruintn len); the application provides the cipher suite number for which it wants information, the address of a block of memory allocated to receive that information, and the size in bytes of that block of memory.
... ssl_getciphersuiteinfo fills that caller-supplied memory with information from the sslciphersuiteinfo structure for that cipher suite.
Rhino scopes and contexts
however, initstandardobjects is an expensive method to call and it allocates a fair amount of memory.
...such behavior may not be suitable with shared scopes since if a script by mistake adds a property to a library object from the shared scope, that object would not be garbage collected until there are no active references to the shared scope potentially leading to memory leaks.
Rhino serialization
reading the serialized object back into memory is similarly simple: fileinputstream fis = new fileinputstream(filename); objectinputstream in = new scriptableinputstream(fis, scope); object deserialized = in.readobject(); in.close(); again, we need the scope to create our serialization stream class.
...(it might be possible to save the java bytecodes in an array and then load the class upon deserialization, but at best that would eat up a lot of memory for just this feature.) one way around this is to compile the functions using the jsc tool: $ cat f.js function f() { return 3; } $ java -classpath js.jarorg.mozilla.javascript.tools.jsc.main f.js $ cat test2.js loadclass("f"); serialize(f, "f.ser"); g = deserialize("f.ser"); print(g()); $ java -classpath 'js.jar;.'org.mozilla.javascript.tools.shell.main test2.js 3 now the function f is compiled ...
Creating JavaScript jstest reftests
in the javascript shell, an uncaught exception or out of memory error will terminate the shell with an exit code of 3.
...to make the situation even more complex, newer c++ compilers will abort the browser with a typical exit code of 5 by throwing a c++ exception when an out of memory error occurs.
Tracing JIT
the architecture-specific methods found in these files are the only functions within nanojit or tracemonkey that emit raw bytes of machine-code into memory.
... if the side exit condition indicates that the trace exited unsuccessfully -- due to encountering sufficient memory pressure to trigger a garbage collection, running out of native stack space, expiring a timer or any similar abnormal condition -- the monitor returns to monitoring mode.
JS::SourceBufferHolder
if ownership is not given to the sourcebufferholder, then the memory must be kept alive until the js compilation is complete.
... any code calling sourcebufferholder::take() must guarantee to keep the memory alive until js compilation completes.
JSClass
(this example uses the c++ new and delete keywords, but the application can allocate the memory for private data however it likes.
...jscontext *cx, unsigned argc, jsval *vp) { js::callargs args = js::callargsfromvp(argc, vp); jsobject *obj = js_newobjectforconstructor(cx, &printer_class, args); /* spidermonkey 31 or older * jsobject *obj = js_newobjectforconstructor(cx, &printer_class, vp); */ if (!obj) return false; myprinter *p = new myprinter; if (p == null) { js_reportoutofmemory(cx); return false; } js_setprivate(cx, obj, p); args.rval().setobject(*obj); /* spidermonkey 31 or older * js_set_rval(cx, vp, object_to_jsval(obj)); */ return true; } { js_initclass(cx, global, js::null(), &printer_class, printer_construct, 1, null, null, null, null); } see also mxr id search for jsclass jsclass.flags js_getclass j...
JSNative
js_reporterror or js_reportoutofmemory) or raise an exception (using js_setpendingexception), and the callback must return false.
... see also mxr id search for jsnative js::callargs js_reporterror js_reportoutofmemory js_setpendingexception ...
JSPrincipals
this is used for memory management.
...this is used for memory management.
JS_DestroyContext
js_destroycontext additionally performs garbage collection to reclaim any memory that was being used by cx's global object.
...js_destroycontextmaybegc may or may not perform garbage collection; the engine makes an educated guess as to whether enough memory would be reclaimed to justify the work.
JS_GC
performs garbage collection in the js memory pool.
...garbage collection frees memory so that it can be reused by the system.
JS_NewUCString
description js_newstring creates and returns a new string, using the memory starting at buf and ending at buf + length as the character storage.
...on success, the javascript engine adopts responsibility for memory management of this region.
JS_SetPrivate
memory management of this field is the application's responsibility.
...in particular: if you allocate memory for private data, you must free it, typically in a jsclass.finalize callback.
JS_ShutDown
failure to call this method, at present, has no adverse effects other than leaking memory.
...implementation note: this method has been used to clean up memory allocated by jsdtoa.cpp, memory allocated to implement date.now() on windows, and when the internationalization api is enabled, memory internally allocated by icu.
JS_THREADSAFE
each thread that uses the javascript engine must essentially operate in a totally separate region of memory.
...this is because in single-threaded programs, a random call into the jsapi is actually pretty unlikely to trigger gc, especially if the calling thread has not been using up a lot of memory.
Thread Sanitizer
it uses a compile-time instrumentation to check all non-race-free memory access at runtime.
... compile-time blacklisting functions with racy memory access can be flagged, such that the compiler will not instrument them.
WebReplayRoadmap
memory analysis (not yet implemented) analyzing memory usage and leaks in js can be difficult because there is no (or limited) information about where objects were allocated or how the object graph was constructed.
... recordings can be manually analyzed to determine this information, but it would be nice to automate this process and provide a summary of the allocation sites and places where objects are linked together that end up entraining the most amount of memory later on.
Mozilla Projects
david baron that helps extension and chrome developers to find memory leaks.
...it uses a compile-time instrumentation to check all non-race-free memory access at runtime.
Implementation Details
msaa/iaccessible2 at-spi avoiding memory leaks it is the assistive technology's responsibility to watch for events that indicate when windows or content subtrees are being destroyed, and to release all accessible objects related to that window.
... under msaa/ia2, watch for event_hide under atk/at-spi, watch for children-changed:remove to help developers in that regard, there is memory leak monitor, a firefox extension.
Using the Places annotation service
c++ callers will want to use getpageswithannotationcomarray which returns a com array, making memory management much easier and reducing the chance of leaks.
...c++ callers will want to use getpageannotationnamestarray which returns a com array, making memory management much easier and reducing the chance of leaks.
Component Internals
xpcom reads this file into an in-memory database.
... the smart pointer class, nscomptr, for example, which makes reference counting less tedious and error-prone, is not actually frozen, and neither is nsdebug, a class for aiding in tracking down bugs, nor is nsmemory, a class to ensure that everyone uses the same heap, generic factory, and module.
XPCOM hashtable guide
some: hashtables are not packed structures; depending on the implementation, there may be significant wasted memory.
...good hashtable implementations will automatically resize the hashtable in memory if extra space is needed, or if too much space has been allocated.
Introduction to XPCOM for the DOM
in the second case, if we forget to release the object, it will never delete itself, which will cause "memory leaks", i.e.
... the memory is never returned because we keep the object around even if we don't need it.
Components.utils.schedulePreciseGC
this is useful particularly when testing for memory leaks, because normal garbage collection is conservative when javascript code is running to ensure that in-use memory isn't inadvertently collected.
... the scheduled garbage collection has been completed: components.utils.scheduleprecisegc( function() { // this code is executed when the garbage collection has completed } ); since the garbage collection doesn't occur until some time in the future (unlike, for example, components.utils.forcegc(), which causes garbage collection immediately but isn't able to collect all javascript-related memory), the callback lets you know when that's been finished.
nsDependentCString
this class does not own its data, so the creator of objects of this type must take care to ensure that a nstdependentstring continues to reference valid memory for the duration of its use.
... @returns the length of the buffer in characters or 0 if unable to satisfy the request due to low-memory conditions.
nsDependentString
this class does not own its data, so the creator of objects of this type must take care to ensure that a nstdependentstring continues to reference valid memory for the duration of its use.
... @returns the length of the buffer in characters or 0 if unable to satisfy the request due to low-memory conditions.
Free
« xpcom api reference summary the free function frees a block of memory that was allocated by xpcom's memory manager.
... static void free( void* aptr ); parameters aptr [in] the address of the memory block to free.
XPCOM glue classes
nsembedcstring concrete class provides a way to construct a nsacstring object that allocates null-terminated storage.nsembedstringthe nsembedstring concrete class provides a way to construct a nsastring object that allocates null-terminated storage.nsfixedcstringclass declarationnsfixedstringclass declarationnsliteralcstring (external)class declarationnsliteralstring (external)class declarationnsmemorythe nsmemory class provides static helper routines to manage memory.
... these routines allow easy access to xpcom's global nsimemory implementation without having to go through the service manager to get it.nspromiseflatcstringclass declarationnspromiseflatstringclass declarationnsrefptrrefptr (formerly known as nsrefptr, see bug 1207245) is a general class to implement reference counting pointers for objects.
mozIAsyncFavicons
favicon data for favicon uris that are not associated with a page uri via setandfetchfaviconforpage will be stored in memory, but may be expired at any time, so you should make an effort to associate favicon uris with page uris as soon as possible.
...favicon data for favicon uris that are not associated with a page uri via setandfetchfaviconforpage will be stored in memory, but may be expired at any time, so you should make an effort to associate favicon uris with page uris as soon as possible.
mozIStorageAggregateFunction
ength(); nstarray<print64> data(mnumbers); for (pruint32 i = 0; i < data.length(); i++) { print32 value = data[i] - mean; data[i] = value * value; } total = 0; for (pruint32 i = 0; i < data.length(); i++) total += data[i]; nscomptr<nsiwritablevariant> result = do_createinstance("@mozilla.org/variant;1"); ns_ensure_true(result, ns_error_out_of_memory); rv = result->setasdouble(sqrt(double(total) / double(data.length()))); ns_ensure_success(rv, rv); ns_addref(*_result = result); return ns_ok; } private: nstarray<print32> mnumbers; }; // now, register our function with the database connection.
... nscomptr<mozistoragefunction> func = new standarddeviationfunc(); ns_ensure_true(func, ns_error_out_of_memory); nsresult rv = dbconn->createfunction( ns_literal_cstring("stddev"), 1, func ); ns_ensure_success(rv, rv); // run some query that uses the function.
nsIControllers
exceptions thrown ns_error_out_of_memory getcontrollerat() returns the controller instance at the given position.
... exceptions thrown ns_error_out_of_memory removecontroller() removes a controller from the list of controllers.
nsINavHistoryObserver
if an error occurs in between these two steps (for example, an out of memory error), then you may get a notification even though the page doesn't wind up getting deleted.
...if an error occurs in between these two steps (for example, an out of memory error), then you may get a notification even though the page doesn't wind up getting deleted.
nsIStringBundleService
flushbundles() flushes the string bundle cache - useful when the locale changes or when we need to get some extra memory back.
... (automatically called for the memory-pressure and chrome-flush-caches global observer topics.) void flushbundles(); parameters none.
NS_CStringCloneData
the resulting buffer may be freed by calling nsmemory::free.
... see also nsmemory::free, nsacstring ...
NS_CStringContainerInit
therefore, it is generally better to use nsembedcstring, to instantiate a nsacstring object, since it automatically releases allocated memory when the object goes out of scope.
... // call this function to release any memory owned by |str| when done.
NS_CStringContainerInit2
the caller must have allocated the data array using the xpcom memory allocator.
...when the string object is no longer needed, it should be passed to ns_cstringcontainerfinish to free any extra memory that the string object may have allocated.
NS_StringCloneData
the resulting buffer may be freed by calling nsmemory::free.
... see also nsmemory::free, nsastring ...
NS_StringContainerInit
therefore, it is generally better to use nsembedstring, to instantiate a nsastring object, since it automatically releases allocated memory when the object goes out of scope.
... // be sure to call this function to release any memory owned by |str| when done.
XPCOM string functions
this is a low-level api.ns_cstringclonedatathe ns_cstringclonedata function returns a null-terminated, heap allocated copy of the string's internal buffer.ns_cstringcontainerfinishthe ns_cstringcontainerfinish function releases any memory allocated by a nscstringcontainer instance.ns_cstringcontainerinitthe ns_cstringcontainerinit function initializes a nscstringcontainer instance for use as a nsacstring.ns_cstringcontainerinit2the ns_cstringcontainerinit2 function initializes a nscstringcontainer instance for use as a nsacstring.ns_cstringcopythe ns_cstringcopy function copies the value from one nsacstring instance to another.
...this is a low-level api.ns_stringclonedatathe ns_stringclonedata function returns a null-terminated, heap allocated copy of the string's internal buffer.ns_stringcontainerfinishthe ns_stringcontainerfinish function releases any memory allocated by a nsstringcontainer instance.
XPCOM
file and memory management, threads, basic data structures (strings, arrays, variants), etc.
...this article will show you how to use the available interfaces in several mozilla products.aggregating the in-memory datasourcealready_addrefedalready_addrefed in association with nscomptr allows you to assign in a pointer without addrefing it.binary compatibilityif mozilla decides to upgrade to a compiler that does not have the same abi as the current version, any built component may fail.
XPIDL
source and binary compatibility some consumers of idl interfaces create binary plugins that expect the interfaces to be stored in a specific way in memory.
... for types that reference heap-allocated data (strings, arrays, interface pointers, etc), you must follow the xpidl data ownership conventions in order to avoid memory corruption and security vulnerabilities: for in parameters, the caller allocates and deallocates all data.
The Valgrind Test Job
the valgrind test job builds the browser and runs it under valgrind, which can detect various common memory-related errors.
... for example, we have a small number of deliberate but inconsequential memory leaks in the codebase that have corresponding suppressions.
Constants - Plugins
nperr_out_of_memory_error 5 memory allocation failed.
... npres_network_err 1 stream failed due to problems with network, disk i/o, lack of memory, or other problems.
Monster example - Firefox Developer Tools
this article describes a very simple web page that we'll use to illustrate some features of the memory tool.
... so the structure of the memory allocated on the javascript heap is an object containing three arrays, each containing 5000 objects (monsters), each object containing a string and two integers: ...
Waterfall - Firefox Developer Tools
garbage collection red markers in the waterfall represent garbage collection (gc) events, in which spidermonkey (the javascript engine in firefox) walks the heap looking for memory that's no longer reachable and subsequently releasing it.
...in general, though: gc is needed when a lot of memory is being allocated non-incremental gc is usually needed when the memory allocation rate is high enough that spidermonkey may run out of memory during incremental gc when the waterfall records a gc marker it indicates: whether the gc was incremental or not the reason the gc was performed if the gc was non-incremental, the reason it was non-incremental starting in firefox 46, if the gc eve...
AudioBufferSourceNode - Web APIs
the audiobuffersourcenode interface is an audioscheduledsourcenode which represents an audio source consisting of in-memory audio data, stored in an audiobuffer.
... it's especially useful for playing back audio which has particularly stringent timing accuracy requirements, such as for sounds that must match a specific rhythm and can be kept in memory rather than being played from disk or the network.
Audio() - Web APIs
the event-based approach is best: myaudioelement.addeventlistener("canplaythrough", event => { /* the audio is now playable; play it if permissions allow */ myaudioelement.play(); }); memory usage and management if all references to an audio element created using the audio() constructor are deleted, the element itself won't be removed from memory by the javascript runtime's garbage collection mechanism if playback is currently underway.
... instead, the audio will keep playing and the object will remain in memory until playback ends or is paused (such as by calling pause()).
HTMLCanvasElement - Web APIs
htmlcanvaselement.toblob() creates a blob object representing the image contained in the canvas; this file may be cached on the disk or stored in memory at the discretion of the user agent.
... obsolete methods htmlcanvaselement.mozgetasfile() returns a file object representing the image contained in the canvas; this file is a memory-based file, with the specified name.
Using IndexedDB - Web APIs
also, indexeddb storage in browsers' privacy modes only lasts in-memory until the incognito session is closed (private browsing mode for firefox and incognito mode for chrome, but in firefox this is not implemented yet as of april 2020 so you can't use indexeddb in firefox private browsing at all).
...achieving proper international sorting therefore required the entire dataset to be called into memory, and sorting to be performed by client-side javascript, which is not very efficient.
Media Source API - Web APIs
mse gives us finer grained control over how much and how often content is fetched, and some control over memory usage details, such as when buffers are evicted.
... if you do not require explicit control of video quality over time, the rate at which content is fetched, or the rate at which memory is evicted, then the <video> and <source> tags may well be a simple and adequate solution.
Node.removeChild() - Web APIs
WebAPINoderemoveChild
the removed child node still exists in memory, but is no longer part of the dom.
... in the second syntax form, however, there is no oldchild reference kept, so assuming your code has not kept any other reference to the node elsewhere, it will immediately become unusable and irretrievable, and will usually be automatically deleted from memory after a short time.
WebGLRenderingContext.getUniformLocation() - Web APIs
the uniform variable is returned as a webgluniformlocation object, which is an opaque identifier used to specify where in the gpu's memory that uniform variable is located.
... the webgluniformlocation is an opaque value used to uniquely identify the location in the gpu's memory at which the uniform variable is located.
Web Audio API - Web APIs
audiobuffer the audiobuffer interface represents a short audio asset residing in memory, created from an audio file using the audiocontext.decodeaudiodata() method, or created with raw data using audiocontext.createbuffer().
... audiobuffersourcenode the audiobuffersourcenode interface represents an audio source consisting of in-memory audio data, stored in an audiobuffer.
Window.open() - Web APIs
WebAPIWindowopen
best practices <script type="text/javascript"> var windowobjectreference = null; // global variable function openffpromotionpopup() { if(windowobjectreference == null || windowobjectreference.closed) /* if the pointer to the window object in memory does not exist or if such pointer exists but the window was closed */ { windowobjectreference = window.open("http://www.spreadfirefox.com/", "promotefirefoxwindowname", "resizable,scrollbars,status"); /* then create it.
... opening new windows, even with reduced features, uses considerably a lot of the user's system resources (cpu, ram) and involves considerably a lot of coding in the source code (security management, memory management, various code branchings sometimes quite complex, window frame/chrome/toolbars building, window positioning and sizing, etc.).
window.postMessage() - Web APIs
secure shared memory messaging if postmessage() throws when used with sharedarraybuffer objects, you might need to make sure you cross-site isolated your site properly.
... shared memory is gated behind two http headers: cross-origin-opener-policy with same-origin as value (protects your origin from attackers) cross-origin-embedder-policy with require-corp as value (protects victims from your origin) cross-origin-opener-policy: same-origin cross-origin-embedder-policy: require-corp to check if cross origin isolation has been successful, you can test against the crossoriginisolated property available to window and worker contexts: if (crossoriginisolated) { // post sharedarraybuffer } else { // do something else } see also planned changes to shared memory which is starting to roll out to browsers (firefox 79, for example).
will-change - CSS: Cascading Style Sheets
excessive use of will-change will result in excessive memory use and will cause more complex rendering to occur as the browser attempts to prepare for the possible change.
...it may cause the browser to keep the optimization in memory for much longer than it is needed.
TypeError: can't access dead object - JavaScript
the javascript exception "can't access dead object" occurs when firefox disallows add-ons to keep strong references to dom objects after their parent document has been destroyed to improve in memory usage and to prevent memory leaks.
... to improve in memory usage and to prevent memory leaks, firefox disallows add-ons to keep strong references to dom objects after their parent document has been destroyed.
SyntaxError: applying the 'delete' operator to an unqualified name is deprecated - JavaScript
unlike what common belief suggests, the delete operator has nothing to do with directly freeing memory.
... memory management is done indirectly via breaking references, see the memory management page and the delete operator page for more details.
BigInt64Array() constructor - JavaScript
syntax new bigint64array(); new bigint64array(length); new bigint64array(typedarray); new bigint64array(object); new bigint64array(buffer [, byteoffset [, length]]); parameters length when called with a length argument, an internal array buffer is created in memory, of size length multiplied by bytes_per_element bytes, containing zeros.
...the byteoffset and length parameters specify the memory range that will be exposed by the typed array view.
BigUint64Array() constructor - JavaScript
syntax new biguint64array(); new biguint64array(length); new biguint64array(typedarray); new biguint64array(object); new biguint64array(buffer [, byteoffset [, length]]); parameters length when called with a length argument, an internal array buffer is created in memory, of size length multiplied by bytes_per_element bytes, containing zeros.
...the byteoffset and length parameters specify the memory range that will be exposed by the typed array view.
FinalizationRegistry - JavaScript
various runtime heuristics can be used to balance memory usage, responsiveness.
...cleanup callbacks may be useful for reducing memory usage across the course of a program, but are unlikely to be useful otherwise.
Float32Array() constructor - JavaScript
syntax new float32array(); // new in es2017 new float32array(length); new float32array(typedarray); new float32array(object); new float32array(buffer [, byteoffset [, length]]); parameters length when called with a length argument, an internal array buffer is created in memory, of size length multiplied by bytes_per_element bytes, containing zeros.
...the byteoffset and length parameters specify the memory range that will be exposed by the typed array view.
Float64Array() constructor - JavaScript
syntax new float64array(); // new in es2017 new float64array(length); new float64array(typedarray); new float64array(object); new float64array(buffer [, byteoffset [, length]]); parameters length when called with a length argument, an internal array buffer is created in memory, of size length multiplied by bytes_per_element bytes, containing zeros.
...the byteoffset and length parameters specify the memory range that will be exposed by the typed array view.
Int16Array() constructor - JavaScript
syntax new int16array(); // new in es2017 new int16array(length); new int16array(typedarray); new int16array(object); new int16array(buffer [, byteoffset [, length]]); parameters length when called with a length argument, an internal array buffer is created in memory, of size length multiplied by bytes_per_element bytes, containing zeros.
...the byteoffset and length parameters specify the memory range that will be exposed by the typed array view.
Int32Array() constructor - JavaScript
syntax new int32array(); // new in es2017 new int32array(length); new int32array(typedarray); new int32array(object); new int32array(buffer [, byteoffset [, length]]); parameters length when called with a length argument, an internal array buffer is created in memory, of size length multiplied by bytes_per_element bytes, containing zeros.
...the byteoffset and length parameters specify the memory range that will be exposed by the typed array view.
Int8Array() constructor - JavaScript
syntax new int8array(); // new in es2017 new int8array(length); new int8array(typedarray); new int8array(object); new int8array(buffer [, byteoffset [, length]]); parameters length when called with a length argument, an internal array buffer is created in memory, of size length multiplied by bytes_per_element bytes, containing zeros.
...the byteoffset and length parameters specify the memory range that will be exposed by the typed array view.
Uint16Array() constructor - JavaScript
syntax new uint16array(); // new in es2017 new uint16array(length); new uint16array(typedarray); new uint16array(object); new uint16array(buffer [, byteoffset [, length]]); parameters length when called with a length argument, an internal array buffer is created in memory, of size length multiplied by bytes_per_element bytes, containing zeros.
...the byteoffset and length parameters specify the memory range that will be exposed by the typed array view.
Uint32Array() constructor - JavaScript
syntax new uint32array(); // new in es2017 new uint32array(length); new uint32array(typedarray); new uint32array(object); new uint32array(buffer [, byteoffset [, length]]); parameters length when called with a length argument, an internal array buffer is created in memory, of size length multiplied by bytes_per_element bytes, containing zeros.
...the byteoffset and length parameters specify the memory range that will be exposed by the typed array view.
Uint8Array() constructor - JavaScript
syntax new uint8array(); // new in es2017 new uint8array(length); new uint8array(typedarray); new uint8array(object); new uint8array(buffer [, byteoffset [, length]]); parameters length when called with a length argument, an internal array buffer is created in memory, of size length multiplied by bytes_per_element bytes, containing zeros.
...the byteoffset and length parameters specify the memory range that will be exposed by the typed array view.
Uint8ClampedArray() constructor - JavaScript
syntax new uint8clampedarray(); // new in es2017 new uint8clampedarray(length); new uint8clampedarray(typedarray); new uint8clampedarray(object); new uint8clampedarray(buffer [, byteoffset [, length]]); parameters length when called with a length argument, an internal array buffer is created in memory, of size length multiplied by bytes_per_element bytes, containing zeros.
...the byteoffset and length parameters specify the memory range that will be exposed by the typed array view.
WebAssembly.instantiate() - JavaScript
importobject optional an object containing the values to be imported into the newly-created instance, such as functions or webassembly.memory objects.
... importobject optional an object containing the values to be imported into the newly-created instance, such as functions or webassembly.memory objects.
Mobile first - Progressive web apps (PWAs)
this means that mobiles (often the target devices with the least available memory, bandwidth or processing power available) can be given an experience suitable for them as quickly as possible, and as free as possible of extraneous information.
... mobile constraints we have already mentioned the fact that mobiles generally have less memory, processing power and bandwidth than other devices (although bear in mind that smart tvs are also generally pretty low powered.) they also have less viewport size available.
Loading and running WebAssembly code - WebAssembly
to use webassembly in javascript, you first need to pull your module into memory before compilation/instantiation.
...your code might look something like this: webassembly.instantiatestreaming(fetch('mymodule.wasm'), importobject) .then(obj => { // call an exported function: obj.instance.exports.exported_func(); // or access the buffer contents of an exported memory: var i32 = new uint32array(obj.instance.exports.memory.buffer); // or access the elements of an exported table: var table = obj.instance.exports.table; console.log(table.get(0)()); }) note: for more information on how exporting from a webassembly module works, have a read of using the webassembly javascript api, and understanding webassembly text format.
WebAssembly
webassembly.memory() a webassembly.memory object is a resizable arraybuffer that holds the raw bytes of memory accessed by an instance.
... 52notes notes disabled in the firefox 52 extended support release (esr).opera android full support 43safari ios full support 11samsung internet android full support 7.0nodejs full support 8.0.0memorychrome full support 57edge full support 16firefox full support 52notes full support 52notes notes disabled in the firefox 52 extended support release (esr).ie no support noop...
Private Properties - Archive of obsolete content
this is a memory leak waiting to happen.
/loader - Archive of obsolete content
it takes the following set of configuration options: name: a string value which identifies the sandbox in about:memory.
Progress Listeners - Archive of obsolete content
note that the browser uses a weak reference to your listener object, so make sure to keep an external reference to your object to ensure that it stays in memory.
Creating custom Firefox extensions with the Mozilla build system - Archive of obsolete content
personally i would discourage this practice (among other things, static linking means the same code gets loaded more than once into memory, and the code won't be available from javascript or other non-c++ languages) and encourage the use of xpcom wherever possible.
Enhanced Extension Installation - Archive of obsolete content
if updated compatibility information is found this is written into the in-memory representation of the the temporary install manifest and the install function is called recursively, supplying this updated install manifest as the source for _getinstalldata.
Migrating from Internal Linkage to Frozen Linkage - Archive of obsolete content
- #include "nscrt.h" + #include <string.h> const char *str = "foo"; - pruint32 len = nscrt::strlen(str); + pruint32 len = strlen(str); - #include "nscrt.h" + #include "nscrtglue.h" const prunichar str[] = {'f','o','o','\0'}; - pruint32 len = nscrt::strlen(str); + pruint32 len = ns_strlen(str); - #include "nscrt.h" + #include "nsmemory.h" + #include "nscrtglue.h" prunichar* anotherstr = (prunichar*) ns_alloc(100 * sizeof(prunichar)); - prunichar *str = nscrt::strdup(anotherstr); - nscrt::free(str); + prunichar *str = ns_strdup(anotherstr); + ns_free(str); linking for information about the correct libraries to link to when using frozen linkage, see xpcom glue.
Chapter 4: Using XPCOM—Implementing advanced processes - Archive of obsolete content
some xpcom components are services, that means only one instance in memory.
Appendix C: Avoiding using eval in Add-ons - Archive of obsolete content
also, calling .bind() in a tight (inner) loop should be avoided for performance reasons, as calling .bind() does require some work and memory.
Intercepting Page Loads - Archive of obsolete content
we're being careful about removing all listeners, as not doing it has the potential of causing memory leaks.
Observer Notifications - Archive of obsolete content
not doing so will result in memory leaks.
Promises - Archive of obsolete content
the io, memory, and cpu overhead added by sqlite is substantial, and in most cases outweighs the cost of dealing with flat files directly.
Localizing an extension - Archive of obsolete content
if you haven't already created an extension, or would like to refresh your memory, take a look at the previous articles in this series: creating a status bar extension creating a dynamic status bar extension adding preferences to an extension download the sample you can download this article's sample code so you can look at it side-by-side with the article, or to use it as a basis for your own extension.
Environment variables affecting crash reporting - Archive of obsolete content
moz_crashreporter_fulldump store full application memory in the minidump, so you can open it in a microsoft debugger.
MCD, Mission Control Desktop, AKA AutoConfig - Archive of obsolete content
owser configuration ] //----------------------------------------------------------------------- config("autoadmin.refresh_interval", 1440); // auto-update every 24 hours defaultpref("browser.startup.page",1); //0=blank page, 1=homepage, 2=last visited defaultpref("browser.startup.homepage", "http://www/mci/mode-d-emploi.shtml"); lockpref("browser.cache.directory", "/tmp"); lockpref("browser.cache.memory_cache_size", 0); lockpref("mail.server_type",1); // pop=0 imap=1 lockpref("network.hosts.imap_servers", "pop-int"); lockpref("mail.imap.server.pop-int.using_subscription",true); lockpref("mail.imap.server.pop-int.username", env_user); lockpref("mail.identity.useremail", ldap_email); lockpref("mail.identity.username", ldap_gecos); lockpref("mail.check_new_mail", false); lockpref("mail.directory",...
generateCRMFRequest() - Archive of obsolete content
"error:usercancel" the user has canceled the key generation operation "error:internalerror" the software encountered some internal error, such as out of memory ...
importUserCertificates - Archive of obsolete content
if it fails, one of the following error strings will be returned: error string description "error:usercancel" the user canceled the import operation "error:invalidcertificate" one of the certificate packages was incorrectly formatted "error:internalerror" the software encountered some internal error, such as out of memory "error:invalidrequestid" the request id in the response message does not match any outstanding request ...
popChallengeResponse - Archive of obsolete content
"error:internalerror" the software encountered some internal error, such as out of memory challenge-response proof of possession expected input: popodeckeychallcontent ::= sequence of challenge -- one challenge per encryption key certification request (in the -- same order as these requests appear in fullcerttemplates).
Microsummary topics - Archive of obsolete content
getservice(components.interfaces.nsimicrosummaryservice); var generator = microsummaryservice.installgenerator(generatordoc); the service installs the generator by serializing its xml to a file in the user's profile directory and adding the generator to the service's in-memory generator cache.
Remote debugging - Archive of obsolete content
core dump a core dump includes all of the memory of a crashed program.
Standalone XPCOM - Archive of obsolete content
tweeking these options will cause reduction in memory requirements and size.
Stress testing - Archive of obsolete content
tools for microsoft windows consume.exe from the windows server 2003 resource kit tools can consume various resources: physical memory, cpu time, page file, disk space and even the kernel pool.
String Quick Reference - Archive of obsolete content
ng() // foo is a prunichar* string // call // void handlestring(const nsstring& str); handlestring(nsautostring(foo)); new way: wrap with nsdependentstring // foo is a prunichar* string // fix caller to be // void handlestring(const nsastring& str); handlestring(nsdependentstring(foo)); stack-based strings what: use of special stack-oriented classes why: to avoid excess heap allocations and memory leaks wrong: use nsstring/nscstring or raw characters // call getstringvalue(nsastring& out); nsstring value; getstringvalue(value); // call getstringvalue(char** out); char *result; getstringvalue(&result); // don't forget to free result!
Actionscript Acceptance Tests - Archive of obsolete content
in this example the .as test runs out of memory and so the expected exitcode is: 128 testname.out file that specifies expected output.
Cmdline tests - Archive of obsolete content
l -d test.abc, set breakpoint on a line, show local variable value, quit from cmdutils import * def run(): r=runtestlib() r.run_test( 'debugger locals', '%s -d testdata/debug.abc'%r.avmrd, input='break 53\ncontinue\nnext\ninfo locals\nnext\ninfo locals\nquit\n', expectedout=['local1 = undefined','local2 = 10','local2 = 15'] ) use case 2: test -memstats returns memory logs to stdout test contents: start avmshell -memstats test.abc, assert stdout contains 'gross stats', 'sweep m reclaimed n pages.' from cmdutils import * def run(): r=runtestlib() r.run_test(name='memstats', command="%s -memstats testdata/memstats.abc" % r.avm, expectedout=[ 'gross stats', 'managed fra...
Running Tamarin performance tests - Archive of obsolete content
ttvmi (tamarin-tracing interp) -m --memory logs the high water memory mark --aotsdk location of the aot sdk used to compile tests to standalone executables.
Tamarin-central rev 703:2cee46be9ce0 - Archive of obsolete content
tertc-703 vs tc-700: 16.4% fastertc-703 vs flash10: 148.7% fastertc-703 vs tc-700: 0.1% slowertc-703 vs flash10: 5.2% faster linux (ubuntu linux, 2.13 ghz dual core)tc-703 vs tc-700: 6.0% fastertc-703 vs flash10: 1.7% fastertc-703 vs tc-700: 89.5% fastertc-703 vs flash10: 182.0% fastertc-703 vs tc-700: 6.1% fastertc-703 vs flash10: 1.4% faster performance testuite memory metric the following is a comparison of the current tamarin-central (tc-703) versus the prior build (tc-700).
Tamarin Roadmap - Archive of obsolete content
tc jan '09 feature links status integrate the tt string class tamarin:string implementation tamarin:strings bug 465506 complete enhanced c++ profiler enhance memory profiler to work in release builds and be more performant in progress enable lir for arm targets bug 460764 complete amd64 nanojit bug 464476 in progress port nanojit to powerpc bug 458077 complete add mac-x64 and linux-x64 buildbots complete fail build on assertion in acceptance tests complete merge tracking bug bug 469836 in progress tc feb '09 spring backlog tbd.
Treehydra Manual - Archive of obsolete content
a memory state in the programming language being analyzed.
Using addresses of stack variables with NSPR threads on win16 - Archive of obsolete content
with the speed of today's processors (even those running win-16), the copying of 10 - 50 kilobytes of data between two locations in memory is barely measurable 1.
Elements - Archive of obsolete content
you can use this to unload resources to free memory.
Install script template - Archive of obsolete content
ption = "my exemplary plugin mine all mine"; // registry constant paths // these will be used when the win32 registry keys are written var hkey_local_machine = "hkey_local_machine"; var hkey_current_user = "hkey_current_user"; var reg_moz_path = "software\\mozillaplugins"; // my own error code in case secondary installation fails var nosecondaryinstall = 1; // error return codes need some memory var err; // error return codes when we try and install to the current browser var errblock1; // error return codes when we try and do a secondary installation var errblock2 = 0; // global variable containing our secondary install location var secondaryfolder; //special error values used by the cycore developers (www.cycore.com) who helped make this install script var exceptionoccurederror...
Return Codes - Archive of obsolete content
y does not exist value_does_not_exist -243 registry value does not exist invalid_signature -260 the signature used in the xpi is not valid invalid_hash -261 the hash used in the xpi is not valid invalid_hash_type -262 the has used in the xpi is not of a valid type out_of_memory -299 insufficient memory for operation gestalt_unknown_error -5550 gestalt_invalid_argument -5551 ...
Dynamically modifying XUL-based user interface - Archive of obsolete content
todo: simple example of a xul document and a tree you can think of a document as an in-memory representation of valid html or well-formed xml such as xhtml or xul.
The Joy of XUL - Archive of obsolete content
this led to increased screen drawing performance and reduced memory and disk footprint requirements of the application.
SeaMonkey - making custom toolbar (SM ver. 1.x) - Archive of obsolete content
note: you may have to restart the machine, as seamonkey often is configured to keep portions of code in memory.
XUL Structure - Archive of obsolete content
by default, mozilla applications parse xul files and scripts, and store a pre-compiled version in memory for the remainder of the application session.
Building XULRunner with Python - Archive of obsolete content
development machine setup first a word of warning that zonealarm has exhibited memory leaks that cause build machines to crash with rather spurious errors.
Using SOAP in XULRunner 1.9 - Archive of obsolete content
xulrunner 1.8.* - using an old xulrunner is certainly an option but brings up a host of speed, stability and memory issues.
External resources for plugin creation - Archive of obsolete content
n many attempts to distill down useful information on creating them: colonelpanic.net building a firefox plugin - part one: discusses the difference between npapi and npruntime and summarizes the basic apis needed to create a plugin building a firefox plugin - part two: discusses the basic lifecycle of a npapi plugin building a firefox plugin - part three: discusses npobjects and how to use them memory management in npapi: discusses how memory is managed in a npapi plugin browser plugins vs extensions (add-ons) -- the difference: discusses the oft-misunderstood difference between a plugin and an extension wikipedia npapi: history and general information about npapi plugins and extensions: the general difference between them boom swagger boom writing an npapi plugin for mac os x ...
NPN_CreateObject - Archive of obsolete content
if no allocate function is provided, malloc() is called to allocate enough memory to hold an npobject.
NPN_GetValue - Archive of obsolete content
memory for this string must be freed by the plugin via npn_memfree().
NPN_PluginThreadAsyncCall - Archive of obsolete content
plug-ins should perform appropriate synchronization with the code in their npp_destroy() routine to ensure correct execution and avoid memory leaks.
NPN_PostURLNotify - Archive of obsolete content
description npn_posturlnotify functions identically to npn_posturl, with these exceptions: npn_posturlnotify supports specifying headers when posting a memory buffer.
NPN_RequestRead - Archive of obsolete content
typically, the only streams that are inherently seekable are those from in-memory or on-disk data, or from http servers that support byte-range requests.
NPN_UTF8FromIdentifier - Archive of obsolete content
description once the caller is done with the returned string, the caller is responsible for deallocating the memory used by the string by calling npn_memfree().
NPN_Write - Archive of obsolete content
this number depends on the size of the browser's memory buffers, the number of active streams, and other factors.
NPP_Destroy - Archive of obsolete content
to ensure that the browser does not crash or leak memory when the saved data is discarded, npsaveddata's buf field should be a flat structure (a simple structure with no allocated substructures) allocated with npn_memalloc.
NPP_DestroyStream - Archive of obsolete content
npres_network_err: stream failed due to problems with network, disk i/o, lack of memory, or other problems.
NPP_New - Archive of obsolete content
the plug-in is responsible for freeing the memory for the npsaveddata and the buffer it contains.
NPP_URLNotify - Archive of obsolete content
npres_network_err: stream failed due to problems with network, disk i/o, lack of memory, or other problems.
NPP_Write - Archive of obsolete content
the buf parameter is not persistent, so the plug-in must process data immediately or allocate memory and save a copy of it.
NPP_WriteReady - Archive of obsolete content
if the plug-in is allocating memory for the entire stream at once (an as_file stream), it can return a very large number.
NPSavedData - Archive of obsolete content
buf pointer to a memory buffer allocated by the plug-in with npn_memalloc().
Updating an extension to support multiple Mozilla applications - Archive of obsolete content
if you haven't already created an extension, or would like to refresh your memory, take a look at the previous articles in this series: creating a status bar extension creating a dynamic status bar extension adding preferences to an extension localizing an extension download the sample you can download this article's sample code so you can look at it side-by-side with the article, or to use it as a basis for your own extension.
Using workers in extensions - Archive of obsolete content
if you haven't already created an extension, or would like to refresh your memory, take a look at the previous articles in this series: creating a status bar extension creating a dynamic status bar extension adding preferences to an extension localizing an extension updating an extension to support multiple mozilla applications download the sample you may download the complete example: download the example.
ECMAScript 2016 to ES.Next support in Mozilla - Archive of obsolete content
new shared memory objects sharedarraybuffer atomics ...
RDF in Mozilla FAQ - Archive of obsolete content
in order to take advantage of this functionality, you must of course be able to express your information in terms of the rdf datasource api, either by using the built-in memory datasource, using rdf/xml to store your information, or writing your own implementation (possibly in javascript) of nsirdfdatasource.
Archive of obsolete content
mmgc mmgc is the tamarin (née macromedia) garbage collector, a memory management library that has been built as part of the avm2/tamarin effort.
Index - Game development
this results in performance and memory usage gains — big image files containing entire level maps are not needed, as they are constructed by small images or image fragments multiple times.
Tiles and tilemaps overview - Game development
this results in performance and memory usage gains — big image files containing entire level maps are not needed, as they are constructed by small images or image fragments multiple times.
Visual JS GE - Game development
this is good because it is memory safe.
Algorithm - MDN Web Docs Glossary: Definitions of Web-related terms
there are also machine learning algorithms such as linear regression, logistic regression, decision tree, random forest, support vector machine, recurrent neural network (rnn), long short term memory (lstm) neural network, convolutional neural network (cnn), deep convolutional neural network and so on.
DoS attack - MDN Web Docs Glossary: Definitions of Web-related terms
computers have limited resources, for example computation power or memory.
Denial of Service - MDN Web Docs Glossary: Definitions of Web-related terms
computers have limited resources, for example computation power or memory.
Dominator - MDN Web Docs Glossary: Definitions of Web-related terms
so objects that a dominates contribute to the retained size of a: that is, the total amount of memory that could be freed if a itself were freed.
Endianness - MDN Web Docs Glossary: Definitions of Web-related terms
each memory storage location has an index or address.
Immutable - MDN Web Docs Glossary: Definitions of Web-related terms
an object can be immutable for various reasons, for example: to improve performance (no planning for the object's future changes) to reduce memory use (make object references instead of cloning the whole object) thread-safety (multiple threads can reference the same object without interfering with one other) learn more general knowledge immutable on wikipedia ...
Reference - MDN Web Docs Glossary: Definitions of Web-related terms
in computing, a reference is a value that indirectly accesses data to retrieve a variable or a record in a computer's memory or other storage device.
SISD - MDN Web Docs Glossary: Definitions of Web-related terms
in sisd architecture, a single processor executes a single instruction and operates on a single data point in memory.
buffer - MDN Web Docs Glossary: Definitions of Web-related terms
a buffer is a storage in physical memory used to temporarily store data while it is being transferred from one place to another.
MDN Web Docs Glossary: Definitions of Web-related terms
xlink xml xpath xquery xslt other 404 502 alpn at-rule attack byte-order mark character set client cryptosystem debug digital signature execution flex-direction glsl interface library memory management routers self-executing anonymous function stylesheet vector image ...
How CSS works - Learn web development
the dom represents the document in the computer's memory.
Common questions - Learn web development
this set of articles shows you how to use the developer tools in firefox to debug and improve performance of your website, using the tools to check memory usage, the javascript call tree, the number of dom nodes being rendered, and more.
The web and web standards - Learn web development
the following simple javascript will store a reference to our paragraph in memory and change the text inside it: let pelem = document.queryselector('p'); pelem.textcontent = 'we changed the text!'; in the house analogy, javascript is like the cooker, tv, microwave, or hairdryer — the things that give your house useful functionality tooling once you've learned the "raw" technologies that can be used to build web pages (such as html, css, and javascript), you'll soon...
Images in HTML - Learn web development
note: you should read a quick primer on urls and paths to refresh your memory on relative and absolute urls before continuing.
Graceful asynchronous programming with Promises - Learn web development
promise terminology recap there was a lot to cover in the above section, so let's go back over it quickly to give you a short guide that you can bookmark and use to refresh your memory in the future.
Client-side storage - Learn web development
the most interesting parts of this are those shown below — to actually display our video blobs in a <video> element, we need to create object urls (internal urls that point to the video blobs stored in memory) using the url.createobjecturl() method.
Introduction to the server side - Learn web development
a web server might send warning messages to site administrators alerting them to low memory on the server, or suspicious user activity.
Deployment and next steps - Learn web development
there are no additional runtimes or dependencies to download, parse, execute, and keep running in memory.
Working with Svelte stores - Learn web development
we'll also take care of clearing the timeout when the alert component is unmounted to prevent memory leaks.
Introduction to cross browser testing - Learn web development
troubleshooting javascript from previous topics to refresh your memory if needed).
Handling common JavaScript problems - Learn web development
note: addy osmani's writing fast, memory-efficient javascript contains a lot of detail and some excellent tips for boosting javascript performance.
Strategies for carrying out testing - Learn web development
note: you need a lot of hard disk space available to run virtual machine emulations; each operating system you emulate can take up a lot of memory.
Adding a new CSS property
(which set the property is in is given in the specification, which says "inherited: yes" or "inherited: no" in the property's definition.) also note that some of the style structs intentionally contain only properties set/reset by a particular common shorthand property; this improves the effectiveness of some of the performance and memory optimizations done with the rule tree, and thus we should avoid adding a property not reset by that shorthand to such a struct.
What to do and what not to do in Bugzilla
blocker blocks development and/or testing work critical crashes, loss of data, severe memory leak major major loss of function normal regular issue, some loss of functionality under specific circumstances minor minor loss of function, or other problem where easy workaround is present trivial cosmetic problem like misspelled words or misaligned text enhancement request for enhancement the blocker severity should be used ve...
Command line options
you must use an upper case p on linux with versions older than 7.x, as there lower case invokes purify mode (memory and leak detection).
Creating Sandboxed HTTP Connections
in order to avoid memory leaks, the observer needs to be removed at one point.
Capturing a minidump
unlike the minidumps submitted by breakpad, these minidumps contain the complete contents of program memory.
Old Thunderbird build
if on windows you get link errors like "lnk1102: out of memory" or "lnk1318: unexpected pdb error; ok (0)", try deleting the largest .pdb files before rushing out the door to buy more ram.
Simple Thunderbird build
if on windows you get link errors like "lnk1102: out of memory" or "lnk1318: unexpected pdb error; ok (0)", try deleting the largest .pdb files before rushing out the door to buy more ram.
Creating Custom Events That Can Pass Data
nsdomevent* it = new nsdommyevent(aprescontext, aevent); if (nsnull == it) { return ns_error_out_of_memory; } return callqueryinterface(it, adomevent); } in general though i'd strongly recommend using a function the way that everyone else does.
Eclipse CDT Manual Setup
before you proceed any further, check that your changes to eclipse's memory limits have taken effect and are present in eclipse/help > about eclipse > installation details > configuration.
Reviewer Checklist
resource leaks in java, memory leaks are largely due to singletons holding on to caches and collections, or observers sticking around, or runnables sitting in a queue.
Error codes returned by Mozilla APIs
ns_error_out_of_memory (0x8007000e) this error occurs when there is not enough memory available to carry out an operation, or an error occurred trying to allocate memory.
Roll your own browser: An embedding how-to
activex control: an activex control allowing for embedding the gecko layout engine.obsolete since gecko 7.0 llmozlib & ubrowser: a static library that allows you to embed gecko and render pages to memory.
Getting from Content to Layout
gecko maintains two separate representations of a document in memory: the content tree and the frame tree.
How to get a stacktrace with WinDbg
a developer may ask you for a "minidump" or a "full memory dump", which are files containing more information about the process.
How to Report a Hung Firefox
(if you're experiencing high cpu usage and firefox eventually recovers from a hang, you should try the instructions at reporting a performance problem instead.) is the rest of your system busy (high cpu or memory usage, or high disk activity)?
IME handling guide
on the other hand, tsftextstore cannot cache character rects since if there are a lot of characters, caching the rects require a lot of cpu cost (to compute each rect) and memory.
IPC Protocol Definition Language (IPDL)
current docs ipdl tutorial quick start: creating a new protocol quick start: extending a protocol ipdl type serialization ipdl best practices ipdl glossary pbackground future planned docs ipdl language reference error and shutdown handling in ipdl protocols how ipdl uses processes, threads, and sockets ipdl shared memory ...
DownloadLastDir.jsm
however, when private browsing mode is enabled, the last download directory path is instead maintained in memory, and the preference is not changed.
JavaScript OS.Constants
emfile too many open files in the process enametoolong name too long enfile too many open files on the system enoent no such file or directory enomem cannot allocate memory enospc no space on device enotdir is not a directory enxio device no configured or does not support operation eopnotsupp (not always available under windows) operation not supported.
XPCOMUtils.jsm
this parameter should not be the component itself because that would cause a memory leak.
Localizing with Mozilla Translator
like most cat tools, mozillatranslator employs glossaries and translation memory to leverage your work from previous translations, thus cutting time and effort when localizing new versions of mozilla applications.
MathML In Action
bugzilla has a big memory for these things, and besides, how would your problems be fixed if they are not reported?!
Automated performance testing and sheriffing
current list of automated systems we are tracking (at least to some degree): talos: the main performance system, run on virtually every check-in to an integration branch build metrics: a grab bag of performance metrics generated by the build system arewefastyet: a generic javascript and web benchmarking system areweslimyet: a memory benchmarking tool ...
GC and CC logs
generating logs from within firefox to manually generate gc and cc logs, navigate to about:memory and use the buttons under "save gc & cc logs." "save concise" will generate a smaller cc log, "save verbose" will provide a more detailed cc log.
JS::PerfMeasurement
lementation can measure eleven different types of low-level hardware and software events: events that can be measured bitmask passed to constructor counter variable what it measures perfmeasurement::cpu_cycles .cpu_cycles raw cpu clock cycles ::instructions .instructions total instructions executed ::cache_references .cache_references total number of memory accesses ::cache_misses .cache_misses memory accesses that missed the cache ::branch_instructions .branch_instructions branch instructions executed ::branch_misses .branch_misses branch instructions that were not predicted correctly ::bus_cycles .bus_cycles total memory bus cycles ::page_faults .page_fau...
Profiling with the Firefox Profiler
thgis requires the following command: $ xpcshell -m -i -n -e ' const ci = components.interfaces; const cc = components.classes; var profiler = cc["@mozilla.org/tools/profiler;1"].getservice(ci.nsiprofiler); profiler.startprofiler( 10000000 /* = profiler memory */, 1 /* = sample rate: 100µs with patch, 1ms without */, ["stackwalk", "js"], 2 /* = features, and number of features.
Profiling with the Gecko Profiler and Local Symbols on Windows
it looks like we consume too much memory when creating the symbol table for this to work in 32 bit firefox builds.
Reporting a Performance Problem
note that increasing the buffer size uses more memory and can make capturing a profile take longer.
nglayout.debug.disable_xul_cache
false: cache xul documents in memory and save the cache to disk on exit to improve performance.
L20n
l20n and translation memory exchange (tmx) how l20n impacts the translation memory exchange standard for translation memory data.
Leak Monitor
david baron that helps extension and chrome developers to find memory leaks.
MailNews automated testing
performance testing mail leak and bloat tests these tests start up thunderbird or seamonkey and record any leaks found, as well as the total memory requirement.
MailNews
leak and bloat tests this page describes how to perform tests that measure memory leaks and bloat for mailnews and its sub-components.
Optimizing Applications For NSPR
the general rules of 16 bit large model memory restrictions apply to applications using nspr on windows 3.1.
IPC Semaphores
note: see also named shared memory ipc semaphore functions ipc semaphore functions pr_opensemaphore pr_waitsemaphore pr_postsemaphore pr_closesemaphore pr_deletesemaphore ...
PL_HashTableAdd
pl_hashtableadd returns null if there is not enough memory to create a new entry.
PL_strfree
frees memory allocated by pl_strdup.
PRIOMethods
fsync flush all in-memory buffers of file to permanent store.
PR_AtomicDecrement
the modification to memory is unconditional.
PR_CEnterMonitor
if unsuccessful (the monitor cache needs to be expanded and the system is out of memory), the function returns null.
PR_Close
on successful return, pr_close frees the dynamic memory and other resources identified by the fd parameter.
PR_FreeLibraryName
frees memory allocated by nspr for library names and path names.
PR_GetUniqueIdentity
if the function cannot allocate enough dynamic memory, it fails and returns the value pr_invalid_io_layer with the error code pr_out_of_memory_error.
PR_ReadDir
the flags parameter is an enum of type prdirflags: typedef enum prdirflags { pr_skip_none = 0x0, pr_skip_dot = 0x1, pr_skip_dot_dot = 0x2, pr_skip_both = 0x3, pr_skip_hidden = 0x4 } prdirflags; the memory associated with the returned prdirentry structure is managed by nspr.
PR_Sync
description pr_sync writes all the in-memory buffered data of the specified file to the disk.
PR_dtoa
decpt a pointer to a memory location where the runtime will store the offset, relative to the beginning of the output string, of the conversion's decimal point.
JSS FAQ
MozillaProjectsNSSJSSJSS FAQ
in general, a key is a handle to an underlying object on a pkcs #11 token, not merely a java object residing in memory.
NSS_3.11.10_release_notes.html
bug 398680: assertion botch in ssl3_registerserverhelloextensionsender doing second handshake with ssl_forcehandshake bug 403240: threads hanging in nss_initlock bug 403888: memory leak in trustdomain.c bug 416067: certutil -l -h token doesn't report token authentication failure bug 417637: tstclnt crashes if -p option is not specified bug 421634: don't send an sni client hello extension bearing an ipv6 address bug 422918: add verisign class 3 public primary ca - g5 to nss bug 424152: add thawte primary root ca to nss bug 424169: add geotrust primary certificati...
NSS 3.12.5 release_notes
memory for the strings are owned by the caller, who is free to free them once nss_contextinit returns.
NSS 3.12.9 release notes
bug 596798: win_rand.c (among others) uses unsafe _snwprintf bug 597622: do not use the sec_error_bad_info_access_location error code for bad crl distribution point urls bug 619268: memory leaks in cert_changecerttrust and cert_savesmimeprofile bug 585518: addtrust qualified ca root serial wrong in certdata.txt trust entry bug 337433: need cert_findcertbynicknameoremailaddrbyusage bug 592939: expired cas in certdata.txt documentation <for a="" class="new " documentation="" href="/en/index.html#documentation" list="" nss="" of="" pages="" primary="" rel="internal" see=""...
NSS 3.15.2 release notes
bug 884178 - add pk11_cipherfinal macro bugs fixed in nss 3.15.2 bug 734007 - sizeof() used incorrectly bug 900971 - nssutil_readsecmoddb() leaks memory bug 681839 - allow ssl_handshakenegotiatedextension to be called before the handshake is finished.
NSS 3.16 release notes
bug 974693: fix a memory corruption in sec_pkcs12_new_asafe.
NSS 3.17.4 release notes
bug 1094492: fixed a memory corruption issue during failure of keypair generation.
NSS 3.19.2.4 release notes
security fixes in nss 3.19.2.4 the following security fixes from nss 3.21 have been backported to nss 3.19.2.4: bug 1185033 / cve-2016-1979 - use-after-free during processing of der encoded keys in nss bug 1209546 / cve-2016-1978 - use-after-free in nss during ssl connections in low memory bug 1190248 / cve-2016-1938 - errors in mp_div and mp_exptmod cryptographic functions in nss compatibility nss 3.19.2.4 shared libraries are backward compatible with all older nss 3.x shared libraries.
NSS 3.49 release notes
bug 1606025 - remove -wmaybe-uninitialized warning in sslsnce.c bug 1606119 - fix ppc hw crypto build failure bug 1605545 - memory leak in pk11install_platform_generate bug 1602288 - fix build failure due to missing posix signal.h bug 1588714 - implement checkarmsupport for win64/aarch64 bug 1585189 - nss database uses 3des instead of aes to encrypt db entries bug 1603257 - fix ubsan issue in softoken ckm_nss_chacha20_ctr initialization bug 1590001 - additional hrr tests (cve-2019-17023) bug 1600144 - treat clienthello...
Enc Dec MAC Using Key Wrap CertReq PKCS10 CSR
v = secfailure; goto cleanup; } /* generate certificate request */ cr = cert_createcertificaterequest(subject, spki, null); if (!cr) { pr_fprintf(pr_stderr, "unable to make certificate request\n"); rv = secfailure; goto cleanup; } arena = port_newarena(der_default_chunksize); if (!arena) { fprintf(stderr, "out of memory"); rv = secfailure; goto cleanup; } exthandle = cert_startcertificaterequestattributes(cr); if (exthandle == null) { port_freearena (arena, pr_false); rv = secfailure; goto cleanup; } cert_finishextensions(exthandle); cert_finishcertificaterequestattributes(cr); /* der encode the request */ encoding = sec_a...
NSS Sample Code Utilities_1
*phrase; prfiledesc *fd; print32 nb; char *pwfile = arg; int i; const long maxpwdfilesize = 4096; char* tokenname = null; int tokenlen = 0; if (!pwfile) return 0; if (retry) { return 0; /* no good retrying - the file contents will be the same */ } phrases = port_zalloc(maxpwdfilesize); if (!phrases) { return 0; /* out of memory */ } fd = pr_open(pwfile, pr_rdonly, 0); if (!fd) { fprintf(stderr, "no password file \"%s\" exists.\n", pwfile); port_free(phrases); return null; } nb = pr_read(fd, phrases, maxpwdfilesize); pr_close(fd); if (nb == 0) { fprintf(stderr,"password file contains no data\n"); port_free(phrases); return null; } if...
Utilities for nss samples
phrase; prfiledesc *fd; print32 nb; char *pwfile = arg; int i; const long maxpwdfilesize = 4096; char* tokenname = null; int tokenlen = 0; if (!pwfile) return 0; if (retry) { return 0; /* no good retrying - the files contents will be the same */ } phrases = port_zalloc(maxpwdfilesize); if (!phrases) { return 0; /* out of memory */ } fd = pr_open(pwfile, pr_rdonly, 0); if (!fd) { fprintf(stderr, "no password file \"%s\" exists.\n", pwfile); port_free(phrases); return null; } nb = pr_read(fd, phrases, maxpwdfilesize); pr_close(fd); if (nb == 0) { fprintf(stderr,"password file contains no data\n"); port_free(phrases); return null; } if...
sample2
pubk); if (!spki) { pr_fprintf(pr_stderr, "unable to create subject public key\n"); rv = secfailure; goto cleanup; } /* generate certificate request */ cr = cert_createcertificaterequest(subject, spki, null); if (!cr) { pr_fprintf(pr_stderr, "unable to make certificate request\n"); rv = secfailure; goto cleanup; } arena = port_newarena(der_default_chunksize); if (!arena) { fprintf(stderr, "out of memory"); rv = secfailure; goto cleanup; } exthandle = cert_startcertificaterequestattributes(cr); if (exthandle == null) { port_freearena (arena, pr_false); rv = secfailure; goto cleanup; } cert_finishextensions(exthandle); cert_finishcertificaterequestattributes(cr); /* der encode the request */ encoding = sec_asn1encodeitem(arena, null, cr, sec_asn1_get(cert_certificaterequesttemplate)); if (encoding...
nss tech note8
the new approach was to use shared memory for the server session cache, and to allow multiple different server session caches to coexist.
PKCS11 FAQ
MozillaProjectsNSSPKCS11FAQ
pkcs #11 certificates that have private keys associated with them are are loaded into the temporary database (in memory) and marked as user certificates.
NSS PKCS11 Functions
this memory must have been allocated with pr_malloc or pl_strdup.
FC_Login
ckr_host_memory: memory allocation failed.
NSC_Login
ckr_host_memory: memory allocation failed.
NSS environment variables
nss_memory_allocation 3.4 nss_disable_unload string (any non-empty value) disable unloading of dynamically loaded nss shared libraries during shutdown.
NSS reference
nss environment variables nss cryptographic module nss tech notes nss tech notes nss memory allocation tools based on nss tools documentation.
pkfnc.html
this memory must have been allocated with pr_malloc or pl_strdup.
sslintro.html
cert_findcertbyname cert_freenicknames cert_getcertnicknames cert_verifycertname cert_verifycertnow pk11_findcertfromnickname pk11_findkeybyanycert pk11_setpasswordfunc pl_strcpy pl_strdup pl_strfree pl_strlen ssl_peercertificate ssl_revealurl ssl_revealpinarg cleanup this portion of an ssl-enabled application consists primarily of closing the socket and freeing memory.
Necko Architecture
the data may be in memory, it may be on disk, or it may be located somewhere else.
Rhino history
also, the implementation effectively leaked memory since most jvms don't really collect unused classes or the strings that are interned as a result of loading a class file.
Rhino optimization
no class files are generated, which may improve memory usage depending on your system.
SpiderMonkey Build Documentation
this can help debug memory leaks and other memory-related problems.
GC Rooting Guide
"gc thing" is the term used to refer to memory allocated and managed by the spidermonkey garbage collector.
SpiderMonkey Internals: Thread Safety
as an optimization, each thread has its own size-classified freelists containing chunks of gc-managed memory ready to be allocated.
Introduction to the JavaScript shell
gc() runs the garbage collector to free up memory.
JS::GetSelfHostedFunction
otherwise, it reports an out-of-memory error and returns null.
JS::SetLargeAllocationFailureCallback
this article covers features introduced in spidermonkey 31 specify a new callback function for large memory allocation failure.
JS::Value
the garbage collector is designed to automatically free unreachable memory.
JSErrorReport
see also mxr id search for jserrorreport js_reporterror js_reportwarning js_reportoutofmemory js_seterrorreporter js_reporterrornumber js_reporterrornumberuc js_reporterrorflagsandnumber js_reporterrorflagsandnumberuc js_reportpendingexception ...
JSFinalizeOp
any jsapi call that would allocate memory from the gc heap will fail if called from a finalizer.
JSObject
these are c/c++ hooks and metadata that govern various aspects of the object's behavior and describe its layout in memory.
JSObjectOps.getRequiredSlot
these operations are infallible, so required slots must be pre-allocated, or implementations must suppress out-of-memory errors.
JSPRINCIPALS_HOLD
description jsprincipals_hold and jsprincipals_drop are used to manage memory for jsprincipals objects.
JSVAL_IS_DOUBLE
syntax jsval_is_double(v) description jsval_is_double(v) is true if v is a number represented in memory as a jsdouble.
JS_AddArgumentFormatter
(at the moment, js_addargumentformatter fails only if there is no memory available to record the registration.) js_addargumentformatter does not copy format, it points at the string storage allocated by the caller, which is typically a string constant.
JS_ConvertArguments
in certain error cases, js_convertarguments calls js_argv_callee(argv), which accesses memory outside the range [argv ..
JS_DestroyRuntime
js_destroyruntime garbage collects and frees the memory previously allocated by js_newruntime.
JS_DestroyScript
description js_destroyscript destroys the given compiled script, freeing the memory allocated to it.
JS_DropExceptionState
description this function destroys the specified jsexceptionstate object, unrooting as necessary any attached exception object and freeing the memory resources associated with the jsexceptionstate object.
JS_EncodeCharacters
the user is responsible for allocating and freeing the memory of the destination string.
JS_EnterLocalRootScope
to remove a gc thing from a local root scope (perhaps to save memory), use js_forgetlocalroot.
JS_GetCompartmentPrivate
memory management for this private data is the application's responsibility.
JS_GetContextPrivate
memory management for this private data is the application's responsibility.
JS_GetRuntimePrivate
memory management for this private data is the application's responsibility.
JS_GetStringChars
(eventually, str becomes unreachable, the garbage collector collects it, and the array is freed by the system.) js_getstringcharsz is the same except that it always returns either a null-terminated string or null, indicating out-of-memory.
JS_LookupProperty
on error or exception (such as running out of memory during the search), the return value is false, and the value left in *vp is undefined.
JS_MakeStringImmutable
in memory it is represented as a pointer to the other string and a pair of integers for the substring's starting point and length, rather than as a separate copy of all the characters.
JS_NewArrayObject
otherwise it reports an error as though by calling js_reportoutofmemory and returns null.
JS_NewContext
this is a memory management tuning parameter which most users should not adjust.
JS_NewFunction
otherwise it reports an out-of-memory error and returns null.
JS_NewObject
the jsclass may be used to override low-level object behavior, including such details as the physical memory layout of the object and how property lookups are done.
JS_NewRuntime
js_newruntime allocates memory for the jsruntime and initializes certain internal runtime structures.
JS_PreventExtensions
for example, if making the object requires an allocation, and that allocation fails, out-of-memory might be reported, and js_preventextensions would return false.
JS_PushArguments
the application must call js_poparguments using the supplied markp stack pointer when done with this stack frame, to free the memory and unroot the jsvals.
JS_RemoveExternalStringFinalizer
unregister a custom string memory manager.
JS_ReportError
to report an out-of-memory error, use js_reportoutofmemory.
JS_SaveExceptionState
either of those two functions frees any memory used by the jsexceptionstate.
JS_SetScriptStackQuota
set the maximum amount of memory a context will use for certain data structures.
JS_freeop
p void * a pointer to the allocated memory to be freed.
JS_updateMallocCounter
malloc counter measures memory pressure for gc scheduling.
PRIVATE_TO_JSVAL
the private data pointer can point to application-defined memory of any type, but the pointer must be two-byte-aligned (that is, (int) p must be even).
Property attributes
this has three effects: the javascript engine does not set aside any memory for the property's value.
JSDBGAPI
jspd_exception jspd_error typedef jspropertydescarray js_propertyiterator js_getpropertydesc js_getpropertydescarray js_putpropertydescarray hooks js_setdebuggerhandler js_setsourcehandler js_setexecutehook js_setcallhook js_setobjecthook js_setthrowhook js_setdebugerrorhook js_setnewscripthook js_setdestroyscripthook js_getglobaldebughooks js_setcontextdebughooks memory usage js_getobjecttotalsize js_getfunctiontotalsize js_getscripttotalsize system objects js_issystemobject js_newsystemobject profiling these functions can be used to profile a spidermonkey application using the mac profiler, shark.
SpiderMonkey 45
178581) js_internjsstring renamed to js_atomizeandpinjsstring (bug 1178581) js_internstringn renamed to js_atomizeandpinstringn (bug 1178581) js_internstring renamed to js_atomizeandpinstring (bug 1178581) js_internucstringn renamed to js_atomizeandpinucstringn (bug 1178581) js_internucstring renamed to js_atomizeandpinucstring (bug 1178581) deleted apis js_getcompartmentstats js_seticumemoryfunctions js_isgcmarkingtracer js_ismarkinggray js_idarraylength js_idarrayget js_destroyidarray js_defaultvalue js_getparent js_setparent js::parsepropertydescriptorobject js_deleteproperty2 js_deletepropertybyid2 js_deleteucproperty2 js_deleteelement2 js_newfunctionbyid js_bindcallable js_decompilefunctionbody js_getlatin1internedstringchars js_gettwobyteinternedstringchars js...
The Rust programming language
in addition, rust offers zero-cost abstractions, move semantics, guaranteed memory safety, threads with no data races, trait-based generics, pattern matching, type inference, and efficient c bindings, with a minimum runtime size.
Places Expiration
algorithm expiration is based on hardware specs, specifically on memory size and available disk space.
XPCOM Glue without mozalloc
starting with xulrunner 2.0, the frozen linkage dependent glue (xpcomglue_s.lib on windows, libxpcomglue_s.a on linux and mac) is dependent on the new infallible memory allocation routines (mozalloc).
Using XPCOM Utilities to Make Things Easier
// in idl: attribute acstring data; nsembedcstring data; method->getdata(data); // now to extract the data from the url class: const char* astringurl = url.get(); note that the memory pointed to by astringurl after the call to url.get() is owned by the url string object.
Language bindings
this is useful particularly when testing for memory leaks, because normal garbage collection is conservative when javascript code is running to ensure that in-use memory isn't inadvertently collected.components.utils.setgczealthis method lets scripts set the zeal level for garbage collection.
Observer Notifications
this lets extensions inject api into chrome windows as needed (see nsidomglobalpropertyinitializer for an alternative method of doing this, which uses significantly less memory).
NS_ConvertASCIItoUTF16
@returns the length of the buffer in characters or 0 if unable to satisfy the request due to low-memory conditions.
NS_ConvertUTF16toUTF8
@returns the length of the buffer in characters or 0 if unable to satisfy the request due to low-memory conditions.
NS_ConvertUTF8toUTF16
@returns the length of the buffer in characters or 0 if unable to satisfy the request due to low-memory conditions.
NS_LossyConvertUTF16toASCII
@returns the length of the buffer in characters or 0 if unable to satisfy the request due to low-memory conditions.
Append
remarks if insufficient memory is available to perform the assignment, then the string's internal buffer will point to a static empty (zero-length) buffer.
Assign
remarks if insufficient memory is available to perform the assignment, then the string's internal buffer will point to a static empty (zero-length) buffer.
Insert
remarks if insufficient memory is available to perform the assignment, then the string's internal buffer will point to a static empty (zero-length) buffer.
Replace
remarks if insufficient memory is available to perform the assignment, then the string's internal buffer will point to a static empty (zero-length) buffer.
nsACString_internal
@returns the length of the buffer in characters or 0 if unable to satisfy the request due to low-memory conditions.
Append
remarks if insufficient memory is available to perform the assignment, then the string's internal buffer will point to a static empty (zero-length) buffer.
Assign
remarks if insufficient memory is available to perform the assignment, then the string's internal buffer will point to a static empty (zero-length) buffer.
Insert
remarks if insufficient memory is available to perform the assignment, then the string's internal buffer will point to a static empty (zero-length) buffer.
Replace
remarks if insufficient memory is available to perform the assignment, then the string's internal buffer will point to a static empty (zero-length) buffer.
nsAString_internal
@returns the length of the buffer in characters or 0 if unable to satisfy the request due to low-memory conditions.
nsAdoptingCString
@returns the length of the buffer in characters or 0 if unable to satisfy the request due to low-memory conditions.
nsAdoptingString
@returns the length of the buffer in characters or 0 if unable to satisfy the request due to low-memory conditions.
nsAutoString
@returns the length of the buffer in characters or 0 if unable to satisfy the request due to low-memory conditions.
nsCAutoString
@returns the length of the buffer in characters or 0 if unable to satisfy the request due to low-memory conditions.
nsCString
@returns the length of the buffer in characters or 0 if unable to satisfy the request due to low-memory conditions.
nsDependentCSubstring
@returns the length of the buffer in characters or 0 if unable to satisfy the request due to low-memory conditions.
nsDependentSubstring
@returns the length of the buffer in characters or 0 if unable to satisfy the request due to low-memory conditions.
nsFixedCString
@returns the length of the buffer in characters or 0 if unable to satisfy the request due to low-memory conditions.
nsFixedString
@returns the length of the buffer in characters or 0 if unable to satisfy the request due to low-memory conditions.
nsPromiseFlatCString
@returns the length of the buffer in characters or 0 if unable to satisfy the request due to low-memory conditions.
nsPromiseFlatString
@returns the length of the buffer in characters or 0 if unable to satisfy the request due to low-memory conditions.
RefPtr
memory leak?
nsString
@returns the length of the buffer in characters or 0 if unable to satisfy the request due to low-memory conditions.
nsXPIDLCString
@returns the length of the buffer in characters or 0 if unable to satisfy the request due to low-memory conditions.
nsXPIDLString
@returns the length of the buffer in characters or 0 if unable to satisfy the request due to low-memory conditions.
imgIContainer
if the lock count drops to zero, the image is allowed to discard its frame data to save memory.
imgIRequest
status_load_complete 0x4 the data has been fully loaded to memory, but not necessarily fully decoded.
mozIStorageError
nomem 7 a memory allocation failed.
mozIStorageProgressHandler
see also storage mozstorage introduction and how-to article mozistorageconnection database connection to a specific file or in-memory data storage mozistoragestatement create and execute sql statements on a sqlite database.
mozIStorageStatement
void execute(); see also storage introduction and how-to article mozistorageconnection database connection to a specific file or in-memory data storage mozistoragevaluearray wraps an array of sql values, such as a result row.
mozIStorageValueArray
see also storage introduction and how-to article mozistorageconnection database connection to a specific file or in-memory data storage mozistoragestatement create and execute sql statements on a sqlite database.
nsIArray
ns_error_out_of_memory if there is not enough memory to complete the operation.
nsIAuthModule
the buffer at aouttoken must be recycled with a call to nsimemory.free().
nsIAuthPrompt2
note: this method may throw any exception when the prompt fails to queue, for example because of out-of-memory error.
nsICache
the cache service decides which cache device to use based on "some resource management calculation." store_in_memory 1 the storage policy of a cache entry determines the device(s) to which it belongs.
nsICacheEntryDescriptor
this fails if the storage policy is not store_in_memory.
nsICacheService
for example, a non-stream-based cache entry can only have a storage policy of store_in_memory.
nsICachingChannel
cacheforofflineuse boolean specifies whether or not the data should be placed in the offline cache, in addition to normal memory/disk caching.
nsICategoryManager
this pointer must be released using nsimemory.free() when it is no longer needed.
nsIFactory
lockfactory() this method provides the client a way to keep the component in memory until it is finished with it.
nsIINIParserWriter
the sections are built in memory before the text of the ini file is generated, so you can add properties to the file in any order, regardless of section.
alloc
this content is now available at nsimemory.alloc().
free
this content is now available at nsimemory.free().
heapMinimize
this content is now available at nsimemory.heapminimize().
realloc
this content is now available at nsimemory.realloc().
nsIModule
if the component module is native (that is, as part of a dll), then this method may be called to determine whether or not the dll may be unloaded from memory.
nsIMsgDatabase
the caller should free when done using nsmemory.free().
nsIMsgMessageService
note if we're offline, then even if alocalonly is false, we won't stream over the network return the url that gets run, if any ismsginmemcache() determines whether a message is in the memory cache.
nsIMutableArray
any of these methods may throw ns_error_out_of_memory when the array must grow to complete the call, but the allocation fails.
nsINavHistoryResult
while the result waits to be collected it will stay in memory, and continue to update itself, potentially causing unwanted additional work.
nsIObserver
failure to do so may result in memory leaks.
nsIPluginHost
the caller is required to free the resulting memory with nsimalloc.free().
Component; nsIPrefBranch
remarks registering as a preference observer can open an object to potential cyclical references which will cause memory leaks.
nsIPrefBranch2
remarks registering as a preference observer can open an object to potential cyclical references which will cause memory leaks.
nsIProperties
nsmemory.h defines the macro ns_free_xpcom_allocated_pointer_array, which can be used to free akeys when it is no longer needed.
nsISHistory
for example to control memory usage of the browser, to prevent users from loading documents from history, to erase evidence of prior page loads and so on.
nsISHistoryListener
entries can be removed from session history for various reasons; for example to control the browser's memory usage, to prevent users from loading documents from history, to erase evidence of prior page loads, etc.
nsITaskbarTabPreview
an application may have as many tab previews as memory allows.
nsIURI
note: this is an optimization, allowing you to check the scheme of the uri without having to get the scheme and do the comparison yourself; this saves memory allocations.
nsIUpdate
mem_error (1) a memory error occurred.
nsIZipReader
test() tests the integrity of the archive by performing a crc check on each item expanded into memory.
XPCOM Interface Reference
ationnsiinterfacerequestornsijscidnsijsidnsijsiidnsijsonnsijetpacknsijetpackservicensijumplistbuildernsijumplistitemnsilivemarkservicensiloadgroupnsilocalfilensilocalfilemacnsilocalensilocaleservicensilogininfonsiloginmanagernsiloginmanagercryptonsiloginmanageriemigrationhelpernsiloginmanagerprompternsiloginmanagerstoragensiloginmetainfonsimimeinputstreamnsimacdocksupportnsimarkupdocumentviewernsimemorynsimemorymultireporternsimemorymultireportercallbacknsimemoryreporternsimemoryreportermanagernsimenuboxobjectnsimessagebroadcasternsimessagelistenernsimessagelistenermanagernsimessagesendernsimessagewakeupservicensimessengernsimicrosummarynsimicrosummarygeneratornsimicrosummaryobservernsimicrosummaryservicensimicrosummarysetnsimimeconverternsimimeheadersnsimodulensimsgaccountnsimsgaccountmanagerex...
NS ENSURE TRUE
syntax ns_ensure_true( expr, return-value ); usage nsresult mozmyclass::mozstringmucking() { char *foo = new char[123]; ns_ensure_true(foo, ns_error_out_of_memory); // this is equivalent to doing: if (!foo) return ns_error_out_of_memory; // thou shalt not return ns_error_failure..
XPCOM Interface Reference by grouping
nsipromptservice zipfile nsizipentry nsizipreader nsizipreadercache nsizipwriter file nsifilepicker nsifileprotocolhandler nsifilespec nsifilestreams nsifileutilities nsifileview memory nsimemory network channel nsichannel nsichanneleventsink nsirequest nsirequestobserver nsiresumablechannel nsidnsservice nsiftpchannel nsiftpeventsink nsihttpchannel nsihttpchannelinternal nsihttpheadervisi...
NS_CStringContainerFinish
« xpcom api reference summary the ns_cstringcontainerfinish function releases any memory allocated by a nscstringcontainer instance.
NS_StringContainerFinish
« xpcom api reference summary the ns_stringcontainerfinish function releases any memory allocated by a nsstringcontainer instance.
XPCOM reference
core xpcom functionsxpcom provides a number of global functions which are used to initialize and shut down the xpcom library, as well as to allocate memory, get access to services, and to instantiate interfaces.foldersthe folder classes all implement the nsimsgfolder interface.
Setting HTTP request headers
failing to do that may cause memory leaks.
Storage
see also mozistorageconnection database connection to a specific file or in-memory data storage mozistoragestatement create and execute sql statements on a sqlite database.
Use SQLite
es(dbconnection); return dbconnection; }, _dbcreatetables: function(adbconnection) { for(var name in this.dbschema.tables) adbconnection.createtable(name, this.dbschema.tables[name]); }, }; window.addeventlistener("load", function(e) { tbirdsqlite.onload(e); }, false); this is another practical sample on how to handle opendatabase and sql queries on the client side, using in-memory (blob) storage of 2mb: var db = opendatabase('mydb', '1.0', 'test db', 2 * 1024 * 1024); var msg; db.transaction(function (tx) { tx.executesql('create table if not exists logs (id unique, log)'); tx.executesql('insert into logs (id, log) values (1, "foobar")'); tx.executesql('insert into logs (id, log) values (2, "logmsg")'); msg = '<p>log message created and row inserted.</p>'; docume...
Using C struct and pointers
once we have a ctypes char pointer that points to a buffer of known size, we modiify the contents of the memory block as follows: ptr.contents = string("hello world from javascript!!!"); string() adds the '\0' character.
Declaring types
primitive types primitive types are those types that represent a single value in memory, as opposed to arrays, structures, or functions.
Using js-ctypes
memory management moved to memory management page.
CData
a cdata object represents a c value or function located in memory.
CType
pointertype these represent pointers to data in memory.
PointerType
writing to this value writes the c conversion of the data into the pointed-to memory.
js-ctypes
using js-ctypes ctypes.open custom native file standard os libraries finding window handles working with data working with arraybuffers declaring types declaring and calling functions declaring and using callbacks type conversion memory management chromeworker js-ctypes reference a reference guide to the js-ctypes api.
Accessibility Inspector - Firefox Developer Tools
while it’s running, it slows performance and takes up memory; therefore it interferes with the metrics from other panels such as memory and performance as well as overall browser performance.
Debugger.Frame - Firefox Developer Tools
it is also not called when unwinding a frame due to an over-recursion or out-of-memory exception.
Debugger - Firefox Developer Tools
in those cases the old exception does not continue to propagate; it is discarded.) this handler is not called when unwinding a frame due to an over-recursion or out-of-memory exception.
Tutorial: Set a breakpoint - Firefox Developer Tools
the scratchpad panel should appear at the top of the toolbox alongside the console, debugger, and memory panels.
Debugger-API - Firefox Developer Tools
also omitted is the debugger’s debugger.memory instance, which holds methods and accessors for observing the debuggee’s memory use.
DOM allocation example - Firefox Developer Tools
this article describes a very simple web page that we'll use to illustrate some features of the memory tool.
UI Tour - Firefox Developer Tools
the allocations view is like the call tree view, but for allocations: it shows you which functions in your page are allocating the most memory over the course of the profile.
Firefox Developer Tools
memory figure out which objects are keeping memory in use.
Animation.onremove - Web APIs
this could result in a huge animations list, which could create a memory leak.
Animation.persist() - Web APIs
WebAPIAnimationpersist
this could result in a huge animations list, which could create a memory leak.
Animation.replaceState - Web APIs
this could result in a huge animations list, which could create a memory leak.
Animation - Web APIs
WebAPIAnimation
if they are indefinite (i.e., forwards-filling), this can result in a huge animations list, which could create a memory leak.
AudioBuffer() - Web APIs
rangeerror there isn't enough memory available to allocate the buffer.
AudioBuffer - Web APIs
the audiobuffer interface represents a short audio asset residing in memory, created from an audio file using the audiocontext.decodeaudiodata() method, or from raw data using audiocontext.createbuffer().
BaseAudioContext.createBuffer() - Web APIs
rangeerror there isn't enough memory available to allocate the buffer.
CSSOMString - Web APIs
while browser implementations that use utf-8 internally to represent strings in memory can use usvstring when the specification says cssomstring, implementations that already represent strings as 16-bit sequences might choose to use domstring instead.
A basic ray-caster - Web APIs
not exactly a new member of the id software family, but pretty decent considering it's a fully interpreted environment, and i didn't have to worry about memory allocation or video modes or coding inner routines in assembler or anything.
CrashReportBody - Web APIs
current possible reasons are: oom: the browser ran out of memory.
DOMException - Web APIs
out of memory) (no legacy code value and constant name).
Binary strings - Web APIs
WebAPIDOMStringBinary
this means that each code unit requires two bytes of memory and is able to represent 65535 different code points.
Document.createDocumentFragment() - Web APIs
since the document fragment is in memory and not part of the main dom tree, appending children to it does not cause page reflow (computation of element's position and geometry).
How to create a DOM tree - Web APIs
country="usa"/> </person> <person first-name="jed" last-name="brown"> <address street="321 north st" city="atlanta" state="ga" country="usa"/> <address street="123 west st" city="seattle" state="wa" country="usa"/> <address street="321 south avenue" city="denver" state="co" country="usa"/> </person> </people> the w3c dom api, supported by mozilla, can be used to create an in-memory representation of this document like so: var doc = document.implementation.createdocument("", "", null); var peopleelem = doc.createelement("people"); var personelem1 = doc.createelement("person"); personelem1.setattribute("first-name", "eric"); personelem1.setattribute("middle-initial", "h"); personelem1.setattribute("last-name", "jung"); var addresselem1 = doc.createelement("address"); addre...
Introduction to the DOM - Web APIs
we'll look at how the dom represents an html or xml document in memory and how you use apis to create web content and applications.
Document Object Model (DOM) - Web APIs
the document object model (dom) connects web pages to scripts or programming languages by representing the structure of a document—such as the html representing a web page—in memory.
EffectTiming.fill - Web APIs
WebAPIEffectTimingfill
in order to avoid leaking memory when many filling animations overlap, the browser is required to remove overlapped animations which can lead to surprising results in some cases.
Element.getAttributeNames() - Web APIs
using getattributenames() along with getattribute(), is a memory-efficient and performant alternative to accessing element.attributes.
FileReader.readyState - Web APIs
this could mean that: the entire file or blob has been read into memory, a file read error occurred, or abort() was called and the read was cancelled.
FileHandle API - Web APIs
secured write operation for performance reasons, write (and read) operations are done in memory.
HTMLCanvasElement.getContext() - Web APIs
this will force the use of a software (instead of hardware accelerated) 2d canvas and can save memory when calling getimagedata() frequently.
HTMLCanvasElement.toBlob() - Web APIs
the htmlcanvaselement.toblob() method creates a blob object representing the image contained in the canvas; this file may be cached on the disk or stored in memory at the discretion of the user agent.
In depth: Microtasks and the JavaScript runtime environment - Web APIs
this allows the javascript runtime to track the levels of recursion and the return of results through that recursion, but it also means that each time a function recurses, more memory is needed to create the new context.
Using microtasks in JavaScript with queueMicrotask() - Web APIs
also, creating and destroying promises takes additional overhead both in terms of time and memory that a function which properly enqueues microtasks avoids.
Browser storage limits and eviction criteria - Web APIs
if you had a really low memory situation where the global limit was, say, 8 mb, then the group limit would also be 8 mb.
LockedFile.flush() - Web APIs
WebAPILockedFileflush
for performance reasons, a lockedfile object buffers all its operation in memory.
Navigator - Web APIs
WebAPINavigator
navigator.devicememory read only returns the amount of device memory in gigabytes.
Network Information API - Web APIs
e = connection.effectivetype; function updateconnectionstatus() { console.log("connection type changed from " + type + " to " + connection.effectivetype); type = connection.effectivetype; } connection.addeventlistener('change', updateconnectionstatus); preload large resources the connection object is useful for deciding whether to preload resources that take large amounts of bandwidth or memory.
OffscreenCanvas.getContext() - Web APIs
this will force the use of a software (instead of hardware accelerated) 2d canvas and can save memory when calling getimagedata() frequently.
Page Visibility API - Web APIs
unloaded the page is in the process of being unloaded from memory.
Performance - Web APIs
performance.memory read only a non-standard extension added in chrome, this property provides an object with basic memory usage information.
RTCDataChannel: error event - Web APIs
examples // strings for each of the sctp cause codes found in rfc // 4960, section 3.3.10: // https://tools.ietf.org/html/rfc4960#section-3.3.10 const sctpcausecodes = [ "no sctp error", "invalid stream identifier", "missing mandatory parameter", "stale cookie error", "sender is out of resource (i.e., memory)", "unable to resolve address", "unrecognized sctp chunk type received", "invalid mandatory parameter", "unrecognized parameters", "no user data (sctp data chunk has no data)", "cookie received while shutting down", "restart of an association with new addresses", "user-initiated abort", "protocol violation" ]; dc.addeventlistener("error", ev => { const err = ev.error; cons...
Request.cache - Web APIs
WebAPIRequestcache
// abortcontroller and signal to allow better memory cleaning.
ServiceWorkerGlobalScope - Web APIs
once successfully registered, a service worker can and will be terminated when idle to conserve memory and processor power.
TextEncoder.prototype.encodeInto() - Web APIs
if the output is expected to be long-lived, it makes sense to compute minimum allocation rounduptobucketsize(s.length), the maximum allocation size s.length * 3, and to have a chosen (as a tradeoff between memory usage and speed) threshold t such that if rounduptobucketsize(s.length) + t >= s.length * 3, you simply allocate for s.length * 3.
TextTrack.mode - Web APIs
WebAPITextTrackmode
this way, the resource fetch and memory usage are avoided unless the cues are actually needed.
WEBGL_compressed_texture_atc - Web APIs
compressed textures reduce the amount of memory needed to store a texture on the gpu, allowing for higher resolution textures or more of the same resolution textures.
WEBGL_compressed_texture_etc - Web APIs
compressed textures reduce the amount of memory needed to store a texture on the gpu, allowing for higher resolution textures or more of the same resolution textures.
WEBGL_compressed_texture_etc1 - Web APIs
compressed textures reduce the amount of memory needed to store a texture on the gpu, allowing for higher resolution textures or more of the same resolution textures.
WEBGL_compressed_texture_pvrtc - Web APIs
compressed textures reduce the amount of memory needed to store a texture on the gpu, allowing for higher resolution textures or more of the same resolution textures.
WEBGL_compressed_texture_s3tc - Web APIs
compressed textures reduce the amount of memory needed to store a texture on the gpu, allowing for higher resolution textures or more of the same resolution textures.
WEBGL_compressed_texture_s3tc_srgb - Web APIs
compressed textures reduce the amount of memory needed to store a texture on the gpu, allowing for higher resolution textures or more of the same resolution textures.
WebGL2RenderingContext.compressedTexSubImage3D() - Web APIs
srcdata an arraybufferview that be used as a data store for the compressed image data in memory.
WebGLProgram - Web APIs
this frees the memory of the linked program.
WebGLRenderingContext.bufferData() - Web APIs
exceptions a gl.out_of_memory error is thrown if the context is unable to create a data store with the given size.
WebGLRenderingContext.compressedTexImage[23]D() - Web APIs
pixels an arraybufferview that be used as a data store for the compressed image data in memory.
WebGLRenderingContext.compressedTexSubImage2D() - Web APIs
pixels an arraybufferview that be used as a data store for the compressed image data in memory.
WebGLRenderingContext.getError() - Web APIs
gl.out_of_memory not enough memory is left to execute the command.
Basic scissoring - Web APIs
a pixel is a picture element (in practice, a point) on the screen, or a single element of the drawing buffer, that area in memory that holds your pixel data (such as rgba color components).
Hello vertex attributes - Web APIs
hello world program in glsl how to send input to a shader program by saving data in gpu memory.
WebGL by example - Web APIs
instead of trying to juggle shaders, geometry, and working with gpu memory, already in the first program, the examples here explore webgl in an incremental way.
WebGL constants - Web APIs
out_of_memory 0x0505 returned from geterror.
Matrix math for the web - Web APIs
at this function in action: let somematrix = [ 4, 0, 0, 0, 0, 3, 0, 0, 0, 0, 5, 0, 4, 8, 4, 1 ] let identitymatrix = [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ]; // returns a new array equivalent to somematrix let somematrixresult = multiplymatrices(identitymatrix, somematrix); important: these matrix functions are written for clarity of explanation, not for speed or memory management.
Using WebRTC data channels - Web APIs
this makes it easy to write efficient routines that make sure there's always data ready to send without over-using memory or swamping the channel completely.
Web Storage API - Web APIs
this has been done to avoid memory issues caused by excessive usage of web storage.
Window: beforeunload event - Web APIs
attaching an event handler/listener to window or document's beforeunload event prevents browsers from using in-memory page navigation caches, like firefox's back-forward cache or webkit's page cache.
Window.devicePixelRatio - Web APIs
var size = 200; canvas.style.width = size + "px"; canvas.style.height = size + "px"; // set actual size in memory (scaled to account for extra pixel density).
XRWebGLLayer() - Web APIs
operationerror the resources (including memory buffers) needed for the layer to operate could not be allocated.
Implementing a Microsoft Active Accessibility (MSAA) Server - Accessibility
they may still exist in memory in a nonfunctional state until the assistive technology completely releases them.
Implementing image sprites in CSS - CSS: Cascading Style Sheets
rather than include each image as a separate image file, it is much more memory- and bandwidth-friendly to send them as a single image; using background position as a way to distinguish between individual images in the same image file, so the number of http requests is reduced.
Audio and video manipulation - Developer guides
use this web audio node type an audio track from an html <audio> or <video> element mediaelementaudiosourcenode a plain raw audio data buffer in memory audiobuffersourcenode an oscillator generating a sine wave or other computed waveform oscillatornode an audio track from webrtc (such as the microphone input you can get using getusermedia().
The Unicode Bidirectional Text Algorithm - Developer guides
this risks the effect spilling over to the outer content right-to-left embedding (rle) u+202b &#x202b; dir="rtl" sets the base direction to rtl, but lets the embedded text interact with the surrounding content, risking spillover effects left-to-right override (lro) u+202d &#x202d; <bdo dir="ltr"> overrides the bidi algorithm, displaying the characters in memory order, from left to right right-to-left override (rlo) u+202e &#x202e; <bdo dir="rtl"> overrides the bidi algorithm and displays the embedded characters in reverse memory order, from right to left closing unicode bidi algorithm control characters character code point html entity markup equivalent description pop directional formatting...
<iframe>: The Inline Frame element - HTML: Hypertext Markup Language
WebHTMLElementiframe
because each browsing context is a complete document environment, every <iframe> in a page requires increased memory and other computing resources.
HTTP headers - HTTP
WebHTTPHeaders
device-memory technically a part of device memory api, this header represents an approximate amount of ram client has.
HTTP Index - HTTP
WebHTTPIndex
115 device-memory client hints, device memory api, http, http header the device-memory header is a device memory api header that works like client hints header which represents the approximate amount of ram client device has.
Closures - JavaScript
16)'} ]; helptext.foreach(function(text) { document.getelementbyid(text.id).onfocus = function() { showhelp(text.help); } }); } setuphelp(); performance considerations it is unwise to unnecessarily create functions within other functions if closures are not needed for a particular task, as it will negatively affect script performance both in terms of processing speed and memory consumption.
JavaScript data types and data structures - JavaScript
objects in computer science, an object is a value in memory which is possibly referenced by an identifier.
Concurrency model and the event loop - JavaScript
heap objects are allocated in a heap which is just a name to denote a large (mostly unstructured) region of memory.
Functions - JavaScript
the memory can be freed only when the returned inside is no longer accessible.
Grammar and types - JavaScript
for example: '37' - 7 // 30 '37' + 7 // "377" converting strings to numbers in the case that a value representing a number is in memory as a string, there are methods for conversion.
Indexed collections - JavaScript
in order to access the memory contained in a buffer, you need to use a view.
Introduction - JavaScript
type safety means, for instance, that you can't cast a java integer into an object reference or access private memory by corrupting java bytecodes.
Keyed collections - JavaScript
they will not leak memory, so it can be safe to use dom elements as a key and mark them for tracking purposes, for example.
Regular expressions - JavaScript
the last example includes parentheses, which are used as a memory device.
Atomics - JavaScript
atomic operations when memory is shared, multiple threads can read and write the same data in memory.
DataView - JavaScript
description endianness multi-byte number formats are represented in memory differently depending on machine architecture — see endianness for an explanation.
Object.freeze() - JavaScript
> object.freeze(1) typeerror: 1 is not an object // es5 code > object.freeze(1) 1 // es2015 code an arraybufferview with elements will cause a typeerror, as they are views over memory and will definitely cause other possible issues: > object.freeze(new uint8array(0)) // no elements uint8array [] > object.freeze(new uint8array(1)) // has elements typeerror: cannot freeze array buffer views with elements > object.freeze(new dataview(new arraybuffer(32))) // no elements dataview {} > object.freeze(new float64array(new arraybuffer(64), 63, 0)) // no elements float64array [] >...
WeakMap - JavaScript
the second inconvenience is a memory leak because the arrays ensure that references to each key and each value are maintained indefinitely.
WebAssembly.Instance() constructor - JavaScript
importobject optional an object containing the values to be imported into the newly-created instance, such as functions or webassembly.memory objects.
WebAssembly.instantiateStreaming() - JavaScript
importobject optional an object containing the values to be imported into the newly-created instance, such as functions or webassembly.memory objects.
Standard built-in objects - JavaScript
intl intl.collator intl.datetimeformat intl.listformat intl.numberformat intl.pluralrules intl.relativetimeformat intl.locale webassembly webassembly webassembly.module webassembly.instance webassembly.memory webassembly.table webassembly.compileerror webassembly.linkerror webassembly.runtimeerror other arguments ...
import - JavaScript
when importing statically significantly increases your program's memory usage and there is a low likelihood that you will need the code you are importing.
var - JavaScript
javascript has automatic memory management, and it would make no sense to be able to use the delete operator on a global variable.
JavaScript reference - JavaScript
ntrol abstraction promise generator generatorfunction asyncfunction reflection reflect proxy internationalization intl intl.collator intl.datetimeformat intl.displaynames intl.listformat intl.locale intl.numberformat intl.pluralrules intl.relativetimeformat webassembly webassembly webassembly.module webassembly.instance webassembly.memory webassembly.table webassembly.compileerror webassembly.linkerror webassembly.runtimeerror statements javascript statements and declarations control flowblock break continue empty if...else switch throw try...catch declarations var let const functions and classes function function* async function return class iterations do...while ...
JavaScript
memory management memory life cycle and garbage collection in javascript.
Web audio codec guide - Web media technologies
the effect of codec configuration on encoded audio output audio codecs typically employ cleverly-designed and highly-complex mathematical algorithms to take source audio data and compress it to take substantially less space in memory or network bandwidth.
Image file type and format guide - Web media technologies
bit depth, on the other hand, is the total number of bits used to represent each pixel in memory.
Handling media support issues in web content - Web media technologies
detecting playback errors adapting presentation with css memory management ...
Digital video concepts - Web media technologies
yuv data representation because the image is represented using more detail in greyscale than in color, the values of y', u, and v are not typically stored together, one sample per pixel, the way rgb images are stored in memory.
Populating the page: how browsers work - Web Performance
layers do improve performance, but are expensive when it comes to memory management, so should not be overused as part of web performance optimization strategies.
Understanding latency - Web Performance
however server performance has improved as computer memory, or cpu, has improved.
Web Performance
reading performance charts developer tools provide information on performance, memory, and network requests.
Installing and uninstalling web apps - Progressive web apps (PWAs)
by reducing the user experience differential between the web app and native apps on the user's device, you reduce both the loss of any muscle memory they have revolving around the native interface of the device and the sensation of "something isn't quite right" that users can experience when switching between native and web-based apps.
The building blocks of responsive design - Progressive web apps (PWAs)
mobiles in general (more commonly in some parts of the world than others) are on lower bandwidth connections and have less memory available than desktop devices, so yes, those extra kilobytes really do count.
filterRes - SVG: Scalable Vector Graphics
too large of a value may result in slow processing and large memory usage.
<discard> - SVG: Scalable Vector Graphics
WebSVGElementdiscard
this is particularly useful to help svg viewers conserve memory while displaying long-running documents.
SVG documentation index - SVG: Scalable Vector Graphics
WebSVGIndex
this is particularly useful to help svg viewers conserve memory while displaying long-running documents.
An Overview - XSLT: Extensible Stylesheet Language Transformations
before transformation can take place, the primary xml document(s) and the stylesheet document(s) must be run through a parser, which creates an abstract representation of the structure of the document in memory.
Advanced Example - XSLT: Extensible Stylesheet Language Transformations
slloaded = false; var xsltprocessor = new xsltprocessor(); var mydom; var xmlref = document.implementation.createdocument("", "", null); function sort() { if (!xslloaded){ p = new xmlhttprequest(); p.open("get", "example2.xsl", false); p.send(null); xslref = p.responsexml; xsltprocessor.importstylesheet(xslref); xslloaded = true; } // create a new xml document in memory xmlref = document.implementation.createdocument("", "", null); // we want to move a part of the dom from an html document to an xml document.
Basic Example - XSLT: Extensible Stylesheet Language Transformations
sl:template match="myns:body"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet> the example loads using synchronous xmlhttprequest both the .xsl (xslstylesheet) and the .xml (xmldoc) files into memory.
Compiling a New C/C++ Module to WebAssembly - WebAssembly
emscripten requires a large variety of javascript "glue" code to handle memory allocation, memory leaks, and a host of other problems calling a custom function defined in c if you have a function defined in your c code that you want to call as needed from javascript, you can do this using the emscripten ccall() function, and the emscripten_keepalive declaration (which adds your functions to the exported functions list (see why do functions in my c/c++ source code vanish...