memory-leaks

Custom memory manager works fine in release mode, but not in debug mode

我的未来我决定 提交于 2020-06-01 05:30:10
问题 I'm trying to implement a simple memory manager to experiment with memory pooling mechanism and track memory leaks. I'm using VS2019 and so far my code only runs in release x86 mode. Changing the build configuration to debug or setting target platform to x64, results in an access violation error. Specifically, in debug mode the following line which calculates the available pool size, throws an exception "Unhandled exception thrown: read access violation. p was nullptr." return p->end - p-

Is it leak-safe to keep a Context/Activity instance in RecyclerView.Adapter?

末鹿安然 提交于 2020-05-28 14:45:57
问题 Given an adapter like this: public class MyAdapter extends RecyclerView.Adapter { private final Activity mActivity; private final List<Item> mItemList; public MyAdapter(Activity activity, List<Item> itemList) { this.mActivity = activity; this.mItemList = itemList; } //[...] public void onBindViewHolder(ViewHolder holder, int position) { final Item i = mItemList.get(position); holder.launchButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mActivity

Is it leak-safe to keep a Context/Activity instance in RecyclerView.Adapter?

五迷三道 提交于 2020-05-28 14:45:19
问题 Given an adapter like this: public class MyAdapter extends RecyclerView.Adapter { private final Activity mActivity; private final List<Item> mItemList; public MyAdapter(Activity activity, List<Item> itemList) { this.mActivity = activity; this.mItemList = itemList; } //[...] public void onBindViewHolder(ViewHolder holder, int position) { final Item i = mItemList.get(position); holder.launchButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mActivity

Static context in App class - memory leak

混江龙づ霸主 提交于 2020-05-27 07:20:38
问题 To be able to get app context anywhere in my app, I created App class like this: public class App extends Application { private static Context mContext; public static Context getContext() { return mContext; } @Override public void onCreate() { super.onCreate(); mContext = this } } It works and also it's used in many places in my app where I need to use context (for example, to load resources) and I am not able to inject any other context to use. However, Android Studio throws warning this

Static context in App class - memory leak

99封情书 提交于 2020-05-27 07:17:48
问题 To be able to get app context anywhere in my app, I created App class like this: public class App extends Application { private static Context mContext; public static Context getContext() { return mContext; } @Override public void onCreate() { super.onCreate(); mContext = this } } It works and also it's used in many places in my app where I need to use context (for example, to load resources) and I am not able to inject any other context to use. However, Android Studio throws warning this

My app stops responding when I run it on the Profiling mode

我只是一个虾纸丫 提交于 2020-05-25 03:56:59
问题 I'm having a few OutOfMemory errors on long running sessions of my Android App. To find the cause I'm trying to use the Android Studio Profiler but it stops working and freezes the app within 10 seconds of use. There's a screenshot of the Android Studio Screen. It logs the activities within the first seconds, then it just freezes the app and stops logging anything -> https://ibb.co/QXLhqnz Last lines of my logcat reads (the last lines keep repeating with increasing time, I changed my package

“Other Processes” untraceable memory leaks when using AVAssetResourceLoaderDelegate, iOS Objective C

不问归期 提交于 2020-05-17 06:01:35
问题 I am trying to create an AVURLAsset from an mp4 in memory. So I have created an implementation of AVAssetResourceLoaderDelegate. @interface RLDelegate : NSObject <AVAssetResourceLoaderDelegate> - (instancetype)initWithData:(NSData *)data contentType:(NSString *)contentType; @end @interface RLDelegate() @property (nonatomic) NSData *data; @property (nonatomic) NSString *contentType; @end @implementation RLDelegate - (instancetype)initWithData:(NSData *)data contentType:(NSString *)contentType

How to realloc some memory allocated using calloc?

百般思念 提交于 2020-05-16 10:41:11
问题 I've allocated a string with the calloc function: //string1 and string2 previously declared char *stringClone = calloc(strlen(string1) + 1, sizeof(char)); Now I want to do the same thing on stringClone with a different string. Doing: stringClone = calloc(strlen(string2) + 1, sizeof(char)); I'm gonna have some memory leak, right? How should I use the realloc in this case? 回答1: You can use realloc() to reallocate memory allocated by malloc() , calloc() , realloc() , aligned_alloc() or strdup()

How to realloc some memory allocated using calloc?

点点圈 提交于 2020-05-16 10:38:15
问题 I've allocated a string with the calloc function: //string1 and string2 previously declared char *stringClone = calloc(strlen(string1) + 1, sizeof(char)); Now I want to do the same thing on stringClone with a different string. Doing: stringClone = calloc(strlen(string2) + 1, sizeof(char)); I'm gonna have some memory leak, right? How should I use the realloc in this case? 回答1: You can use realloc() to reallocate memory allocated by malloc() , calloc() , realloc() , aligned_alloc() or strdup()

Are Stores created in the initComponent function memory leaks once the component is destroyed or will these stores be garbage collected?

自古美人都是妖i 提交于 2020-05-15 08:08:49
问题 This is a question that surged from this other one: Best practice to have the same view and store multiple times in ExtJS 4 So in a scenario where stores are created in the initComponent function of a grid. Should I override onDestroy of the grid to also destroy the store ? Or these stores would be garbage collected because simply there are no references to them? 回答1: No, the store will still exist after destroying the Grid No, you will not need to override the destroy method of the grid You