c
c copied to clipboard
Memory Leak in V2beta2Autoscaling
Hi @ityuhui
I found some Leak Case in AutoscalingV2beta2.
Last time I request this Issue. I know this is rare case that Namespace is Null.
But If Namespace is Null, It Occur some problem in System.
`v2beta2_horizontal_pod_autoscaler_list_t* AutoscalingV2beta2API_listNamespacedHorizontalPodAutoscaler(apiClient_t *apiClient, char * _namespace , char * pretty , int allowWatchBookmarks , char * _continue , char * fieldSelector , char * labelSelector , int limit , char * resourceVersion , int timeoutSeconds , int watch ) { list_t *localVarQueryParameters = list_create(); list_t *localVarHeaderParameters = NULL; list_t *localVarFormParameters = NULL; list_t *localVarHeaderType = list_create(); list_t *localVarContentType = NULL; char *localVarBodyParameters = NULL;
// create the path
long sizeOfPath = strlen("/apis/autoscaling/v2beta2/namespaces/{namespace}/horizontalpodautoscalers")+1;
char *localVarPath = malloc(sizeOfPath);
snprintf(localVarPath, sizeOfPath, "/apis/autoscaling/v2beta2/namespaces/{namespace}/horizontalpodautoscalers");
// Path Params
long sizeOfPathParams_namespace = strlen(_namespace)+3 + strlen("{ namespace }");
if(_namespace == NULL) {
goto end;
}`
I think It need to Fix in OpenApiGenerator. Can you fix it?
Do you mean the memory leak of localVarPath if _namespace == NULL ?
@ityuhui yes. If the case does not occur at all, it would be better to remove the case "if(_namespace==NULL)".
The parameter _namespace is required for the "Namespaced" functions such as AutoscalingV2beta2API_listNamespacedHorizontalPodAutoscaler, so if(_namespace==NULL) needs to be checked.
This issue is a memory leak, what I try to fix is to free the memory when _namespace==NULL.
Checked the code and found localVarPath would be freed.
https://github.com/kubernetes-client/c/blob/8f8874e9f5f1023735cc630efb2d354556c0b179/kubernetes/api/AutoscalingV2beta1API.c#L1522-L1524
Is there a memroy leak now ?
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.
This bot triages issues and PRs according to the following rules:
- After 90d of inactivity,
lifecycle/staleis applied - After 30d of inactivity since
lifecycle/stalewas applied,lifecycle/rottenis applied - After 30d of inactivity since
lifecycle/rottenwas applied, the issue is closed
You can:
- Mark this issue or PR as fresh with
/remove-lifecycle stale - Mark this issue or PR as rotten with
/lifecycle rotten - Close this issue or PR with
/close - Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale